home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / pull5xa.arc / PULL5XA.DOC < prev    next >
Text File  |  1989-01-10  |  156KB  |  3,884 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.                            MULTI-LEVEL PULL-DOWN MENUS
  20.                                   USER'S GUIDE
  21.  
  22.                                   Version 5.Xa
  23.                                 January 11, 1989
  24.  
  25.  
  26.                Copyright (C) 1987-1989 Eagle Performance Software
  27.                               All Rights Reserved.
  28.  
  29.  
  30.  
  31.                                _______                     
  32.                           ____|__     |               (tm) 
  33.                        --|       |    |------------------- 
  34.                          |   ____|__  |  Association of    
  35.                          |  |       |_|  Shareware         
  36.                          |__|   o   |    Professionals     
  37.                        -----|   |   |--------------------- 
  38.                             |___|___|    MEMBER            
  39.  
  40.  
  41.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  42.  
  43.  
  44.  
  45.                        T A B L E   O F   C O N T E N T S
  46.  
  47.         1. INTRODUCTION  . . . . . . . . . . . . . . . . . . . . . 4
  48.              Features .  . . . . . . . . . . . . . . . . . . . . . 4
  49.              Using the Manuals . . . . . . . . . . . . . . . . . . 4
  50.              Licensing . . . . . . . . . . . . . . . . . . . . . . 5
  51.              Customer Service  . . . . . . . . . . . . . . . . . . 5
  52.              ASP . . . . . . . . . . . . . . . . . . . . . . . . . 6
  53.  
  54.         2. GETTING STARTED . . . . . . . . . . . . . . . . . . . . 7
  55.              Distribution Files  . . . . . . . . . . . . . . . . . 7
  56.              Demonstration . . . . . . . . . . . . . . . . . . . . 7
  57.  
  58.         3. PROGRAMMING MENUS . . . . . . . . . . . . . . . . . . . 11
  59.              Using the Shell . . . . . . . . . . . . . . . . . . . 11
  60.              Menu Modes  . . . . . . . . . . . . . . . . . . . . . 11
  61.              Line Modes  . . . . . . . . . . . . . . . . . . . . . 14
  62.              HiLite Control  . . . . . . . . . . . . . . . . . . . 15
  63.              Adding Lines  . . . . . . . . . . . . . . . . . . . . 16
  64.              Adding Menus  . . . . . . . . . . . . . . . . . . . . 17
  65.              Adding Submenus . . . . . . . . . . . . . . . . . . . 18
  66.              Help Messages . . . . . . . . . . . . . . . . . . . . 20
  67.              Help Windows  . . . . . . . . . . . . . . . . . . . . 21
  68.              Default Attributes  . . . . . . . . . . . . . . . . . 23
  69.              Standard Borders  . . . . . . . . . . . . . . . . . . 24
  70.              Control Flags . . . . . . . . . . . . . . . . . . . . 24
  71.              Summary . . . . . . . . . . . . . . . . . . . . . . . 26
  72.  
  73.         4. SCREEN DESIGN . . . . . . . . . . . . . . . . . . . . . 27
  74.              Status Line . . . . . . . . . . . . . . . . . . . . . 27
  75.              Top Line Menu . . . . . . . . . . . . . . . . . . . . 27
  76.              Main Menu Row . . . . . . . . . . . . . . . . . . . . 27
  77.              Submenu Row . . . . . . . . . . . . . . . . . . . . . 28
  78.              Work Windows  . . . . . . . . . . . . . . . . . . . . 28
  79.              Message Line  . . . . . . . . . . . . . . . . . . . . 28
  80.              Help Windows  . . . . . . . . . . . . . . . . . . . . 29
  81.              Start-Up Menu . . . . . . . . . . . . . . . . . . . . 29
  82.              Overriding Defaults . . . . . . . . . . . . . . . . . 30
  83.              Summary . . . . . . . . . . . . . . . . . . . . . . . 30
  84.  
  85.         5. DATA WINDOWS  . . . . . . . . . . . . . . . . . . . . . 32
  86.              Data Window Parts . . . . . . . . . . . . . . . . . . 32
  87.              Data Window Record  . . . . . . . . . . . . . . . . . 32
  88.              Data Window Variable  . . . . . . . . . . . . . . . . 33
  89.              Fields  . . . . . . . . . . . . . . . . . . . . . . . 34
  90.              Titles  . . . . . . . . . . . . . . . . . . . . . . . 35
  91.              Editing Keys  . . . . . . . . . . . . . . . . . . . . 36
  92.              Key Sets  . . . . . . . . . . . . . . . . . . . . . . 36
  93.              Key Translation . . . . . . . . . . . . . . . . . . . 37
  94.              Range Checking  . . . . . . . . . . . . . . . . . . . 38
  95.              Help Messages . . . . . . . . . . . . . . . . . . . . 40
  96.              Help Windows  . . . . . . . . . . . . . . . . . . . . 40
  97.              Default Attributes and Border . . . . . . . . . . . . 40
  98.              Default Location  . . . . . . . . . . . . . . . . . . 41
  99.  
  100.  
  101.                                        2
  102.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  103.  
  104.  
  105.              Summary . . . . . . . . . . . . . . . . . . . . . . . 41
  106.  
  107.         6. DATA ENTRY  . . . . . . . . . . . . . . . . . . . . . . 42
  108.              Data Entry vs. Data Windows . . . . . . . . . . . . . 42
  109.              Data Entry Record . . . . . . . . . . . . . . . . . . 42
  110.              Adding Entries  . . . . . . . . . . . . . . . . . . . 43
  111.              Displaying Fields . . . . . . . . . . . . . . . . . . 43
  112.              Sequential Entry  . . . . . . . . . . . . . . . . . . 44
  113.              Edit Mode . . . . . . . . . . . . . . . . . . . . . . 46
  114.              Field Attributes  . . . . . . . . . . . . . . . . . . 47
  115.              Single Entry  . . . . . . . . . . . . . . . . . . . . 47
  116.              Summary . . . . . . . . . . . . . . . . . . . . . . . 47
  117.  
  118.         7. WORK WINDOWS  . . . . . . . . . . . . . . . . . . . . . 48
  119.              Making Steps  . . . . . . . . . . . . . . . . . . . . 48
  120.              Reading the Keyboard  . . . . . . . . . . . . . . . . 49
  121.              Multi-Level Windows . . . . . . . . . . . . . . . . . 51
  122.              Managing Winddows . . . . . . . . . . . . . . . . . . 52
  123.  
  124.         8. USER WINDOWS  . . . . . . . . . . . . . . . . . . . . . 54
  125.              Pull-Down Directory . . . . . . . . . . . . . . . . . 54
  126.              Interface . . . . . . . . . . . . . . . . . . . . . . 55
  127.  
  128.         9. CONDITIONAL COMPILATION . . . . . . . . . . . . . . . . 57
  129.              Define Symbols  . . . . . . . . . . . . . . . . . . . 57
  130.              Recompiling . . . . . . . . . . . . . . . . . . . . . 57
  131.  
  132.        10. TROUBLE SHOOTING  . . . . . . . . . . . . . . . . . . . 58
  133.              Goof Unit . . . . . . . . . . . . . . . . . . . . . . 58
  134.              Far Addresses . . . . . . . . . . . . . . . . . . . . 58
  135.              Multi-tasking . . . . . . . . . . . . . . . . . . . . 59
  136.              Customer Service  . . . . . . . . . . . . . . . . . . 59
  137.  
  138.         APPENDIX A: Other Products . . . . . . . . . . . . . . . . 60
  139.  
  140.         APPENDIX B: Revision History . . . . . . . . . . . . . . . 62
  141.  
  142.         APPENDIX C: Credits  . . . . . . . . . . . . . . . . . . . 63
  143.  
  144.         APPENDIX D: Glossary . . . . . . . . . . . . . . . . . . . 64
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.                                        3
  163.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  164.  
  165.  
  166.    1.  I N T R O D U C T I O N
  167.  
  168.  
  169.    FEATURES
  170.  
  171.    Welcome to PULL multi-level pull-down menus!
  172.  
  173.    You have just obtained a copy of the highest performance pull-down menu 
  174.    utilities available today for Turbo Pascal 5.0 (TP5).  Both novice and 
  175.    professional programmers will appreciate these simple and very powerful 
  176.    utilities that are fully featured and fully configurable.  They work on any 
  177.    all IBM compatibles, including PS/2 and 3270 PC on any video page or any 
  178.    text mode.  
  179.  
  180.    Here are some of the features you will discover:
  181.  
  182.      - Uses the powerful routines of QWIK and WNDW.
  183.      - Work window(s) and complete interface for menus
  184.      - Pull-down menus with 3 menu modes and 7 line modes
  185.      - Pull-down file directory
  186.      - Highlighted command letters
  187.      - Unlimited levels of submenus
  188.      - Unlimited data entry windows for 9 types of data
  189.      - Data entry for the work window(s)
  190.          Free field entry with either fixed column or flexible   
  191.          column length.
  192.          Full editing capability including insert cursor mode
  193.          Fields are easily selected with the cursor keys
  194.          Automatic NumLock for numerical data entry
  195.          Right or left justification for data entry output
  196.          Error messages for invalid data entries
  197.          Error messages for data entries out of range
  198.      - Automatic sizes and locations for menus 
  199.      - Operation by cursor keys or command keys
  200.      - Pull/Pop between work window and nested submenu(s)
  201.      - Programmable control of pull and pop sequences
  202.      - Context-sensitive help windows
  203.      - Message lines for prompts and processing
  204.      - Full working shell for user development
  205.  
  206.    PULL has been designed with a fill-in-the-blank concept.  To get your 
  207.    application up and running, you only need to fill in the appropriate 
  208.    records or variables.
  209.  
  210.    TP4 - The units provided in this distributed file only work under TP5.  
  211.    However, the source code, provided with registration, compiles equally well 
  212.    under TP4.
  213.  
  214. |  Version 5X - This version is simply a TP5 compiled version of PULL42.
  215. |  PULL50 will be out at a later date with other features specific to TP5.
  216.  
  217.  
  218.    USING THE MANUALS
  219.  
  220.    Disk Based Guides - The manuals for PULL are on disk so that you can 
  221.  
  222.  
  223.    Chapter 1, Introduction                                             Page 4
  224.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  225.  
  226.  
  227.    conveniently scan for the topic you are seeking.  You can do this with any 
  228.    list or search utility with a search function.  You can also make a printed 
  229.    copy.  If you have not already printed this manual, refer to the READ.ME 
  230.    file for instructions.  At the present time, no bound manuals are being 
  231.    offered with registration.
  232.  
  233.    User's Guide - This manual, the one your are reading now, assumes that as a 
  234.    programmer you are already familiar with Turbo Pascal 5.0, and that you 
  235.    have a working knowledge of your disk operating system (DOS).  It also 
  236.    assumes that you are familiar with QWIK screen utilities in QWIK5X.ARC and 
  237.    WNDW5XA.ARC.  This manual will provide the basic instructions for creating 
  238.    and managing multi-level pull-down menus.  It also contains a tutorial to 
  239.    guide you step-by-step to create your own application.
  240.  
  241.    Reference Guide - This manual describes in detail all procedures, functions 
  242.    and variables used in PULL.  It is a alphabetically arranged for easy 
  243.    access in a format similar to the TP5 manual.  Use this manual when you 
  244.    have become familiar with the basic principles in the User's guide.
  245.  
  246.  
  247.    LICENSING
  248.  
  249.    Registration - These routines and the documentation have been released for 
  250.    distribution as Shareware.  You have been given the chance to sample the 
  251.    full capability of PULL without risk!  If you find that PULL is a valuable 
  252.    tool, then you are expected to register.  You will find a reasonable 
  253.    licensing schedule found in LICENSE.ARC to meet private or commercial 
  254.    needs.  When registering, be sure to specify the version for Turbo Pascal 
  255.    (such as TP4 or TP5) you wish to receive.
  256.  
  257.    Source Code - All registered users will receive source code when the signed 
  258.    license agreement is returned with the registration.  All source code 
  259.    compiles under TP4 as well as TP5.  The compiled units in the distributed 
  260.    file were compiled with TP5 and only work in TP5.
  261.  
  262.  
  263.    CUSTOMER SERVICE
  264.  
  265.    If you have questions, comments, or suggestions, the Eagle can be contacted 
  266.    by three means - (1) CompuServe, (2) telephone, (3) The Eagle BBS, or 
  267.    (4) mail.
  268.  
  269.    CompuServe - The most dependable way to contact the Eagle is through 
  270.    CompuServe.  James (Jim) H. LeMay has written the TP5 version of PULL.  He 
  271.    can be contacted on the Borland Forum by typing GO BPROGA from the 
  272.    CompuServe main menu.  You will enter the Forum for Turbo Pascal.  You can 
  273.    contact Jim with his PPN number of 76011,217.  Messages can also be left 
  274.    through EasyPlex.
  275.  
  276.    Telephone - Jim can also be reached by phone at (817) 735-4833 on weekdays 
  277.    and Saturday from 9:00 a.m. to 8:00 p.m CST.
  278.  
  279. |  The Eagle BBS - You can also contact us on our 24-hour BBS at (214) 539-
  280. |  9878, 1200/2400 N81.
  281.  
  282.  
  283.  
  284.    Chapter 1, Introduction                                             Page 5
  285.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  286.  
  287.  
  288.    Mail - For registration or problems, please write:
  289.  
  290.        Eagle Performance Software
  291.        TP products
  292.        P.O. Box 122237
  293.        Ft. Worth, TX  76121-2237
  294.  
  295.    In your written request for resolving problems, be sure to include:
  296.  
  297.      . A 5 1/4 inch diskette of compilable source code of the problem.
  298.      . The Eagle product and version number.
  299.      . The computer make and model.
  300.      . The type of video card, video monitor and keyboard.
  301.  
  302.    For identical Turbo C products, write:
  303.  
  304.        Eagle Performance Software
  305.        TC products
  306.        P.O. Box 292786
  307.        Lewisville, TX  75029-2786
  308.  
  309.    Or, contact Jim Gallagher at (214)-539-7855
  310.  
  311.    ASP
  312.  
  313.    PULL is a Shareware program conforming to the standards of the Association 
  314.    of Shareware Professionals (ASP).  You can get more information about ASP 
  315.    by writing to:
  316.     
  317.      Association of Shareware Professionals
  318.      P.O. Box 5786
  319.      Bellevue,WA 98006
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.    Chapter 1, Introduction                                             Page 6
  346.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  347.  
  348.  
  349.    2.  G E T T I N G   S T A R T E D
  350.  
  351.    This section will acquaint you with the files on distribution disk and show 
  352.    you a couple of demonstrations to quickly see what PULL can accomplish.
  353.  
  354.  
  355.    DISTRIBUTION FILES
  356.  
  357.    In this version, PULL5XA.ARC contains:
  358.  
  359.      Read.   .me:   Note of printing instructions for manual.
  360.      Pull5Xa .doc:  This document - a user's guide to PULL.
  361.      PullRef .doc:  PULL Reference Guide document covering each 
  362.                     routine and variable in detail.
  363.      Pull5Xa .tpu:  This unit has the full power of all of its 
  364.                     capabilities.  Please note that because PULL5XA.TPU 
  365.                     uses P5X-VAR.INC all constants have been assigned.  
  366.                     In order to make any changes in the data 
  367.                     requirements, the complete source code will be 
  368.                     required. 
  369.      Pull5Xa-.pas:  Shows the interface portion of PULL5XA.
  370.      P5X-var .inc:  This file is the actual source code which lists 
  371.                     all of the types, constants, and variables used 
  372.                     for PULL5XA.TPU.
  373.      PullDemo.pas:  Fully functional working demo.
  374.      PullWork.pas:  Procedures for the main work window(s).
  375.      PullStat.pas:  Stats to configure the menus including global 
  376.                     keys.
  377.      PullData.pas:  Data to configure data entry windows and fields.
  378.      PullDir-.pas:  Just interface for PULLDIR.PAS. 
  379.      PullDir .tpu:  Unit for a pull-down file directory.
  380.      PullShel.arc:  Contains shell files to develop your own 
  381.                     application.
  382.      Qwik5X  .tpu:  Unit for quick screen writing.
  383.      Strs    .tpu:  Unit from QWIK5X for number-to-string conversions.
  384.      WndwP5Xa.tpu:  Multi-level virtual window unit for PULL.TPU.
  385.      Wutil   .tpu:  Independent utilities unit used in WNDW.TPU.
  386.      Goof    .pas:  Unit to display errors.
  387.      License .arc:  ARC file containing license agreement and ordering 
  388.                     details.
  389.  
  390.  
  391.    DEMONSTRATION
  392.  
  393.    To get the feeling of the speed and features of PULL, let's run the 
  394.    demonstration program that comes with the utilities.  Do the following 
  395.    steps:
  396.  
  397.      1. Copy QWIK5X.TPU to QWIK.TPU.  
  398.      2. Copy WNDWp5XA.TPU (not WNDW5XA.TPU) to WNDW.TPU.  !!!
  399.      3. Copy PULL5XA.TPU to PULL.TPU.
  400.      4. Make, compile and run PULLDEMO.PAS.  (If you get an ERROR 
  401.         15 or 70, then steps 1-3 was not done carefully.)
  402.      5. Follow along in the overview below.
  403.  
  404.  
  405.  
  406.    Chapter 2, Getting Started                                          Page 7
  407.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  408.  
  409.  
  410.    Familiar Environment - You will probably feel right at home with the 
  411.    environment created with PULL as it appears very similar to the TP5 editor.  
  412.    It is interesting to note that PULL was developed with TP3 before TP4 was 
  413.    ever released.  However, you should find the operation quite similar.  
  414.    While you are running the demo, let's get familiar with the format and 
  415.    operation of the environment and follow along with this overview:
  416.  
  417.      . Status Line - Row 1 just holds the title of this program.  It is 
  418.        optional.
  419.  
  420.      . Top Line Menu - Row2 has been optionally assigned to be the top 
  421.        line menu.  Press F10 at any time to access it.
  422.  
  423.      . Work Window - For this demo, Rows 4 to 23 has a 20x78 window for 
  424.        the major part of your input/output.  You can also have multi-
  425.        level work windows.
  426.  
  427.      . Main Menu - To access a main menu, press RETURN or a command 
  428.        letter (LTR) while the top line menu is highlighted on any 
  429.        selection.  Or, you can use a combination of the ALT key and a 
  430.        letter, such as Alt-F to get to the File menu.
  431.  
  432.      . Submenu - A submenu is a menu under a Main Menu.  To access a 
  433.        submenu, press RETURN when the HiLite is at a menu line with the 
  434.        three-bar symbol (which looks like a menu).  You can see three 
  435.        levels of menus by pressing Alt-A/Tires/Brands.
  436.  
  437.    Local Keys and Letter Commands - While a window is shown, several keys 
  438.    operate for just that window.  These keys can be listed in the message line 
  439.    or they can be assumed to be the command letters highlighted on each menu 
  440.    line.
  441.  
  442.      . Help Windows (F1) - While the Brands menu is still showing, 
  443.        press F1 to get context-sensitive help.  A help window is 
  444.        assigned to every window and menu.
  445.  
  446.      . Keys on Message Line - The bottom line of the CRT, being closest 
  447.        to the keyboard, indicates the available keys that can be used 
  448.        for the current context.  It is also used for help or error 
  449.        messages.  While the help window is displayed, the next key 
  450.        pressed will also pass through as a command.  For instance, press 
  451.        RETURN now and see the help window removed and Firestone will 
  452.        also become flagged.
  453.  
  454.      . Pop and Pull (F2) - F2 is a pop-and-pull key that toggles between 
  455.        the pull-down menus and the work window.  Press F2 twice and you 
  456.        will see that it remembers the last menu that was pulled.
  457.  
  458.      . Command Letters (LTR) - If you wanted to select WeatherGuard on 
  459.        the Brands menu, just type the letter "W" which is highlighted.  
  460.        These letters will work in any menu.
  461.  
  462.      . Cursor Keys - All of the cursor keys like the arrows, Home and 
  463.        End keys, have assigned functions as well as the control-shifted 
  464.        cursor keys.  You can discover what they do by experimenting with 
  465.  
  466.  
  467.    Chapter 2, Getting Started                                          Page 8
  468.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  469.  
  470.  
  471.        them in a menu.
  472.  
  473.      . ESC Key - The ESC key always backs out of the current menu/window.
  474.  
  475.    Global Keys - Extended key combinations can be used to access any part of 
  476.    the program.  In this demo, some have been assigned with the ALT key.  
  477.    Press down ALT for a half second and see the available global keys listed 
  478.    on the message line.
  479.  
  480.      . Directory (Alt-D) - Press Alt-D now to get a directory of your 
  481.        disk.  If you would like to continue testing the directory, press 
  482.        F1 for instructions.
  483.  
  484.      . Exit (Alt-X) -  To exit the program, one alternative is to use 
  485.        Alt-X, but don't do it now.
  486.  
  487.      . Top Line Menu (F10) - As mentioned before, to get to the top line 
  488.        menu, press F10 at any time.
  489.  
  490.    Data Entry Windows - Each menu can additionally pull down a data entry 
  491.    window which is indicated with a small dot symbol on the menu line.  These 
  492.    windows are fully configurable and have full editing capability.  They have 
  493.    a free-field entry concept where a entire string is typed and edited before 
  494.    entering.  Let's try a few fields.
  495.  
  496.      . Data Entry Types - Press Alt-E to see a menu of all the data 
  497.        entry types available.  Press RETURN when the HiLite is at a menu 
  498.        line with a small dot symbol.  Pressing RETURN again will exit 
  499.        the window entering the data shown.  You can clear any data 
  500.        entered by pressing ESC which also removes the window.
  501.  
  502.      . Editing - Press "I" while the main menu is still shown and enter 
  503.        a value for the integer.  The virgin entry is highlighted until 
  504.        you press a key.  The entry has full edit capability using the 
  505.        cursor keys and some familiar WordStar control keys.  Press F1 
  506.        for a list.  Even the insert mode is indicated with a half-block 
  507.        cursor.
  508.  
  509.      . Options - All sorts of options are available for these windows 
  510.        including range checking, fixed and flex fields, character 
  511.        control and translation, automatic NumLock, justification, 
  512.        titles, and attributes.
  513.  
  514.    Work Window Data Entry - The same procedures used for the data entry 
  515.    windows can be used for entering data in the work windows.  In addition, 
  516.    PULL has a smart algorithm that knows where several fields are on the 
  517.    screen.  So moving from field to field with all the cursor keys is 
  518.    intuitive.
  519.  
  520.      . Moving the HiLite - Press F2 to get back to the work window with 
  521.        all of the data entry fields.  One field will be highlighted 
  522.        which means it can be moved to select another field.  All of the 
  523.        cursor keys move the HiLite including the control-shifted keys 
  524.        and the Tab and Shift-Tab keys.  Move the HiLite to the Integer 
  525.        field.
  526.  
  527.  
  528.    Chapter 2, Getting Started                                          Page 9
  529.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  530.  
  531.  
  532.  
  533.      . New Values - To enter a new value for the integer, simply start 
  534.        typing some numbers and the HiLite will change colors.  You can 
  535.        see that only numbers and the sign can be entered.  Press RETURN 
  536.        to enter the new value or press ESC to restore the old value.  
  537.  
  538.      . Editing - To edit the value currently shown in a field, press 
  539.        RETURN or any WordStar control key.
  540.  
  541.    Other Features - There are many other features in the menus which will be 
  542.    covered later including menu and line modes, and direct menu control.  You 
  543.    may continue to discover other features in the demo if you want.  When 
  544.    finished, press Alt-X to quit.
  545.  
  546.    Multi-tasking - This demo can easily be set to work in multi-tasking 
  547.    environments by using a file called DESQ5X.ARC.  It is a simple matter of 
  548.    setting the video buffer pointer.  This demo does not include this file.
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.    Chapter 2, Getting Started                                          Page 10
  590.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  591.  
  592.  
  593.    3.  P R O G R A M M I N G   M E N U S
  594.  
  595.    This section will get you familiar with the basics of window programming 
  596.    by starting with very basic menus and then taking you step-by-step through 
  597.    the full variety of options and modes available.
  598.  
  599.  
  600.    USING THE SHELL
  601.  
  602.    Shell Program - Let's experiment will PULL by developing our own 
  603.    application to see how powerful it can be.  A shell program, which is a 
  604.    bare bones application, has been provided with PULL in the file 
  605.    PULLSHEL.ARC.  These files will help you get started for any application.  
  606.    But for now, it can be an excellent learning tool.  To keep these files 
  607.    separate from the PULLDEMO files, create another working directory and 
  608.    unarchive the files in PULLSHEL.ARC.  The files to be extracted are:
  609.  
  610.      PullShel.pas
  611.      PullData.pas
  612.      PullStat.pas
  613.      PullWork.pas
  614.  
  615.    In addition, the follow files need to be on you unit path or copied into 
  616.    the same directory:
  617.  
  618.      Qwik.tpu
  619.      Wndw.tpu
  620.      Wutil.tpu
  621.      Strs.tpu
  622.      Pull.tpu
  623.      Goof.pas
  624.  
  625.    Running the Shell - To make sure we have everything available, load 
  626.    PULLSHEL.PAS, make, and run the program.  You should be able to operate 
  627.    this program the same as PULLDEMO.PAS.  There are only two menus - First 
  628.    and Quit.  To Quit, you can either use the Quit menu or use the global key 
  629.    Alt-X.
  630.  
  631.    Features Available - The shell has every feature available.  They can be 
  632.    added or eliminated.  However, some code cannot be entirely eliminated or 
  633.    altered unless you are registered with the source code.  But let's continue 
  634.    to see what the program can really do.
  635.  
  636.      
  637.    MENU MODES
  638.  
  639.    In this section, we will delve right into the menus and see how they 
  640.    function and what changes can be made.  PULL has three menu modes for every 
  641.    menu - ExecChoice, SingleChoice, and MultipleChoice.  These modes determine 
  642.    how all the lines in the menu can interact as a whole.
  643.  
  644.    SingleChoice - You probably noticed that the First menu had one flag on it 
  645.    because it was a SingleChoice menu.  One and only one item could be flagged 
  646.    by pressing return on any one line.  Let's examine the data record of menu 
  647.    and see how it was made to be single choice.
  648.  
  649.  
  650.    Chapter 3, Programming Menus                                        Page 11
  651.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  652.  
  653.  
  654.  
  655.      1. Load the file PULLSTAT.PAS into the TP editor.
  656.      2. Set PULLSHEL.PAS to be the Primary file.
  657.      3. Search for "with TopMenu".
  658.      4. See the following code:
  659.  
  660.          GetMainMenu (FirstMenu);
  661.          MenuMode := SingleChoice;        
  662.          SingleFlagLine := 3;
  663.          Title   := 'First';
  664.          Line[1] := 'A line';
  665.          Line[2] := 'B line';
  666.          Line[3] := 'C line';
  667.          Line[4] := 'D line';
  668.          DefaultLine := 2;
  669.          MsgLineNum  := ord(MainML);
  670.          HelpWndwNum := ord(MainMenuHW);
  671.          SaveMainMenu;
  672.  
  673.    TopMenu - All these variables are fields in the current menu record called 
  674.    TopMenu.  Notice that MenuMode is set to SingleChoice.  And that's how it 
  675.    is done!  That's all it takes to tell PULL that all items on the menu are 
  676.    single choice.  The program simply takes care of any selection.  So how do 
  677.    you know which line has been selected?  Just get the value of 
  678.    TopMenu.SingleFlagLine.  But also notice that SingleFlagLine has been 
  679.    initially assigned to line 3.  Now you know why the "C line" is flagged 
  680.    when the program first starts.  Setting SingleFlagLine is only needed for 
  681.    the SingleChoice mode.  So how do you make it multiple choice?
  682.  
  683.    MultipleChoice - Let's change MenuMode to MultipleChoice and run the 
  684.    program again.  Do it now.  This time you won't see any flags initially, 
  685.    but each line can be toggled on and off by selecting any line with RETURN.  
  686.    Ok, how do we know which line has been flagged now?  There are several more 
  687.    variables in the menu record other than shown here.  Each Line has an 
  688.    associated boolean variable called Flagged.  For example, if you want to 
  689.    see if Line[3] has been flagged, just test and see if Flagged[3] is true.  
  690.    But suppose we want some of those lines to be initially flagged?
  691.  
  692.    Flags - All the code we have seen is within a procedure called 
  693.    GetUserPullStats which initializes all the menus from InitPull.  The 
  694.    procedure GetMainMenu simply grabs a copy of the current menu record from 
  695.    the heap which happens to be cleared with all zeros at this time.  That 
  696.    means everything is a default value of zero unless we change it.  So, the 
  697.    value of Flagged for each line is false.  Let's see if we can set a couple 
  698.    of lines to be initially true by modifying the code to:
  699.  
  700.      ...
  701.      MenuMode := MultipleChoice;        
  702.      SingleFlagLine := 3;
  703.      Title   := 'First';
  704.      Line[1] := 'A line';  Flagged[1] := true;
  705.      Line[2] := 'B line';  Flagged[2] := true;
  706.      ...
  707.  
  708.    Run the code again and verify that the first two lines are initially 
  709.  
  710.  
  711.    Chapter 3, Programming Menus                                        Page 12
  712.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  713.  
  714.  
  715.    flagged.  If they are, then you are already getting the hang of how to 
  716.    program pull-down menus!  PULL is based on a fill-in-the-blank concept 
  717.    where you supply the data and the program takes care of the rest.
  718.  
  719.    Changed Flags - If there are several flags in the menu and just one is 
  720.    changed, how can you know?  Anytime a flag is altered in the menu, the 
  721.    variable "Changed" in the menu record is set to true which gives a quick 
  722.    survey for any action that may be needed.  This value remains true until 
  723.    your application program manually sets it false.
  724.  
  725.    Executing Procedures - But having a simple flag may not be enough for your 
  726.    application.  Suppose you may also want to DO something as well.  So how 
  727.    can we execute a procedure along with the selection?  Again, each line has 
  728.    an associated execution pointer ProcPtr.  Simply assign any valid procedure 
  729.    address to it and it executes it!  Try the following code:
  730.  
  731.      ...
  732.      MenuMode := MultipleChoice;        
  733.      SingleFlagLine := 3;
  734.      Title   := 'First';
  735.      Line[1] := 'A line';  Flagged[1] := true;  ProcPtr[1] := @DummyProc;
  736.      Line[2] := 'B line';  Flagged[2] := true;  ProcPtr[2] := @DummyProc;
  737.      ...
  738.  
  739.    Run this code and you will find that every time line 1 or 2 is toggled, the 
  740.    message "Processing ..." is displayed briefly on the message line which is 
  741.    all this dummy procedure was supposed to do.  After it is processed, the 
  742.    line is then flagged.  The procedure DummyProc is actually back a few lines 
  743.    in the code just before GetUserPullStats.  This makes it very convenient to 
  744.    have these procedures in the same file, but they don't have to be.  Since 
  745.    the pointer is FAR, these procedures, which have been forced to FAR, can be 
  746.    called from other units as well.
  747.  
  748.    Nil Pointer - So how come procedures were not executed before the pointers 
  749.    were assigned?  Again, all values are zero until changed.  So, the pointer 
  750.    was Nil.  The program simply ignores nil pointers and therefore does not 
  751.    execute anything.
  752.  
  753.    ExecChoice - This mode only executes procedures with ProcPtr and just 
  754.    ignores all flagging.  This is also the default mode.  Let's try this by 
  755.    adding the following braces:
  756.  
  757.      ...
  758.    { MenuMode := MultipleChoice;        
  759.      SingleFlagLine := 3; }
  760.      Title   := 'First';
  761.      Line[1] := 'A line';  Flagged[1] := true;  ProcPtr[1] := @DummyProc;
  762.      Line[2] := 'B line';  Flagged[2] := true;  ProcPtr[2] := @DummyProc;
  763.      ...
  764.  
  765.    Run it again.  You found that both line 1 and 2 executed the dummy 
  766.    process, but the flags weren't toggled.  ExecChoice just ignores flagging.  
  767.    Flags are usually not useful with ExecChoice mode and they can remain 
  768.    false.  Lines 3 and 4 did absolutely nothing since the pointers were nil.
  769.  
  770.  
  771.  
  772.    Chapter 3, Programming Menus                                        Page 13
  773.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  774.  
  775.  
  776.    Default Mode - How come MenuMode was not assigned to ExecChoice and instead 
  777.    was commented out with braces?  We could have if we wanted, but ExecChoice 
  778.    is the default mode with an ordinal value of zero.  So, it saves code to 
  779.    leave it out.
  780.  
  781.      
  782.    LINE MODES
  783.  
  784.    In this section, we will discover how each line in the menu can have one of 
  785.    several different modes and then test each one to see its effect.
  786.  
  787.    Seven Line Modes - Not only does the whole menu have a mode, but each line 
  788.    can have one of seven different modes:
  789.  
  790.      Choice     - permits flagging with Single- or MultipleChoice and 
  791.                   executes the ProcPtr.
  792.      ExecOnly   - executes the ProcPtr without flagging.
  793.      Comment    - bypassed by the highlight.
  794.      Partition  - mid-menu horizontal border.
  795.      ToDataWndw - to pull a data entry window.
  796.      ToSubMenu  - to pull next submenu level.
  797.      ToUserWndw - like ExecOnly, and adds a Submenu symbol.
  798.  
  799.    These names are the actual identifiers used in LineModeType.  Each line has 
  800.    an associated line mode saved in the variable LineMode.  For example, to 
  801.    see what mode is on line 3, just check the value of LineMode[3].
  802.  
  803.    Choice - This is the default and, as you would guess, its ordinal value is 
  804.    zero, so we never have to set it.  With this line mode and a menu mode of 
  805.    SingleChoice or MultipleChoice, the line can be flagged like we have seen 
  806.    in the previous examples.  But it is rare that any menu would have only 
  807.    flags.  So, what other alternatives are there?
  808.  
  809.    ExecOnly - Let's suppose that just one of the lines on our First menu 
  810.    should never be flagged, but all the others can.  How can we isolate it?  
  811.    Back to the current example, revise the menu to be MultipleChoice with the 
  812.    following changes:
  813.  
  814.      ...
  815.      MenuMode := MultipleChoice;        
  816.    { SingleFlagLine := 3; }
  817.      Title   := 'First';
  818.      Line[1] := 'A line';  Flagged[1] := true;       ProcPtr[1] := @DummyProc;
  819.      Line[2] := 'B line';  LineMode[2] := ExecOnly;  ProcPtr[2] := @DummyProc;
  820.      ...
  821.  
  822.    Run it again and see that we can't toggle the flag on line 2 since it was 
  823.    assigned as ExecOnly.  All it does is execute DummyProc even though the 
  824.    menu mode is MultipleChoice.
  825.  
  826.    Comment - Suppose we wanted a title or some type of comment or help message 
  827.    inside the menu itself.  That line should not be considered as a valid 
  828.    choice.  In fact, the line should never be highlighted.  Try changing line 
  829.    3 to the following:
  830.  
  831.  
  832.  
  833.    Chapter 3, Programming Menus                                        Page 14
  834.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  835.  
  836.  
  837.      ...
  838.      Line[2] := 'B line';  LineMode[2] := ExecOnly;  ProcPtr[2] := @DummyProc;
  839.      Line[3] := 'My comment'; LineMode[3] := Comment;
  840.      ...
  841.  
  842.    Run it and move the HiLite up and down.  You can see that the HiLite passes 
  843.    right over line 3 and never accesses it.  By the way, notice also that the 
  844.    first letter of "My comment" was not highlighted as a command letter.  In 
  845.    fact, the entire line is a different attribute.  Also notice that the menu 
  846.    has automatically increased in width to accommodate the new longest line.
  847.  
  848.    Partition - Sometimes it is easier to understand a menu when it is divided 
  849.    into separate sections.  This can be done with the line mode of Partition.  
  850.    Change LineMode[3] as follows:
  851.  
  852.      ...
  853.      Line[2] := 'B line';  LineMode[2] := ExecOnly;  ProcPtr[2] := @DummyProc;
  854.    { Line[3] := 'My comment'; }  LineMode[3] := Partition;
  855.      ...
  856.  
  857.    When you pull down the menu, you will see that line 3 has become an 
  858.    extension of the border with the same style and attribute.  Moving the 
  859.    highlight up and down will also show that the partition is passed over just 
  860.    like a Comment.  Since Line[3] was unecessary and was commented out with 
  861.    braces.
  862.  
  863.    Other Line Modes - There are three remaining modes, ToDataWndw, ToSubMenu, 
  864.    and ToUserWndw, which will pull down another level of a menu or a window.  
  865.    These can also be assigned to LineMode which will be covered in more detail 
  866.    later.
  867.  
  868.  
  869.    HILITE CONTROL
  870.  
  871.    Highlight Line - The menu highlight bar is tracked by a variable called 
  872.    HiLiteLine which is also in TopMenu.  Any time the highlight (also called 
  873.    HiLite) is moved, this value is updated to the current line number and 
  874.    saved.  So, upon re-entering the menu, the HiLite will still be on the same 
  875.    line before as before.
  876.  
  877.    Default Line - The HiLite has to start somewhere.  In our current example, 
  878.    the variable DefaultLine controls the initial line for the HiLite.  When 
  879.    you run it, you can see that the first time the menu is pulled, line 2 is 
  880.    highlighted.  Now move the HiLite down to line 4.  If you exit and re-enter 
  881.    the menu, the HiLite is still on line 4.  So, we know that it always 
  882.    remembers the current line.  But what is the default for DefaultLine?  
  883.    Let's find out.  Comment out the following line:
  884.  
  885.      ...
  886.      Line[4] := 'D line';
  887.    { DefaultLine := 2; }
  888.      MsgLineNum  := ord(MainML);
  889.      ...
  890.  
  891.    Run the program and you will find that the HiLite starts on line 1 and not 
  892.  
  893.  
  894.    Chapter 3, Programming Menus                                        Page 15
  895.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  896.  
  897.  
  898.    zero.  InitPull takes a second look at all menu records and makes sure that 
  899.    all DefaultLines have been set.  If not, it sets DefaultLine to line 1.  
  900.    But suppose we want the HiLite to start on the same line every time the 
  901.    menu is pulled?
  902.  
  903.    Back To Default Line - You can force the HiLite to same initial line by 
  904.    setting BackToDefault to true.  Let's try it on our current example:
  905.  
  906.      ...
  907.      Line[4] := 'D line';
  908.      DefaultLine := 2;
  909.      BackToDefault := true;
  910.      MsgLineNum  := ord(MainML);
  911.      ...
  912.  
  913.    When you pull-down the menu this time, the default line is 2.  But move the 
  914.    HiLite to line 4 and exit the menu.  When the menu is pulled again, the 
  915.    HiLite goes back to line 2.  Looking at the code, the Quit menu record is a 
  916.    few lines down from the First menu.  There you can see that BackToDefault 
  917.    is set to true for that menu as well which would keep a user from 
  918.    inadvertently exiting the program.
  919.  
  920.  
  921.    ADDING LINES
  922.  
  923.    Adding Lines - To add more lines to a menu is a snap - just add a line.  
  924.    Try the following modification on the First menu.
  925.  
  926.      ...
  927.      Line[4] := 'D line';
  928.      Line[5] := 'E line';   { add this line }
  929.      DefaultLine := 2;
  930.      ...
  931.  
  932.    The program automatically knows how many lines are in the menu so that it 
  933.    is sized correctly and the HiLite knows how far to extend.  How many lines 
  934.    can be added?
  935.  
  936.    Maximum Lines - To control the size of the menu record, the maximum number 
  937.    of lines per menu is set by MaxMenuLines.  Go to a file called P5X-VAR.INC 
  938.    and you will find it to be the very first constant in the file and it has 
  939.    been arbitrarily set to 15 lines.  This is one of several configuration 
  940.    constants preset in PULL.  To be able to change these values, you must have 
  941.    the source code to PULL which includes the file P5X-VAR.INC.
  942.  
  943.    Maximum Characters - Each menu line is also limited to a maximum length.  
  944.    You can discover this by testing this code:
  945.  
  946.      ...
  947.      Line[4] := 'D line';
  948.      Line[5] := 'E line is longer than 20 characters'; 
  949.      DefaultLine := 2;
  950.      ...
  951.  
  952.    The menu is only wide enough to accommodate 20 characters which is also 
  953.  
  954.  
  955.    Chapter 3, Programming Menus                                        Page 16
  956.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  957.  
  958.  
  959.    preset with the constant MaxCharsPerLine.
  960.  
  961.  
  962.    ADDING MENUS
  963.  
  964.    Now that you are familiar with the scope of a single menu, you can take the 
  965.    next step and learn how to include additional menus.
  966.  
  967.  
  968.    Main Menu Name - The first thing needed is a name for a new main menu.  On 
  969.    the first page of PULLSTAT.PAS, find an enumerated type called 
  970.    MainMenuNames and insert a new name called SecondMenu:
  971.  
  972.      MainMenuNames = (NoMainMenu,FirstMenu,SecondMenu,QuitMenu);
  973.  
  974.    It is important that these names are in order so that InitPull will 
  975.    arrange them correctly.
  976.  
  977.    Main Menu Record - Now the record of SecondMenu can be added.  Between the 
  978.    FirstMenu and QuitMenu records add the following code:
  979.  
  980.      GetMainMenu (SecondMenu);
  981.      MenuMode := MultipleChoice;        
  982.      Title   := 'Second';
  983.      Line[1] := 'A2 line';
  984.      Line[2] := 'B2 line';
  985.      Line[3] := 'C2 line';
  986.      Line[4] := 'D2 line';
  987.      MsgLineNum  := ord(MainML);
  988.      HelpWndwNum := ord(MainMenuHW);
  989.      SaveMainMenu;
  990.  
  991.    Now run the program.  You can see that there are now three menus that can 
  992.    be pulled down.  They are arranged in the order of the MainMenuNames.  Just 
  993.    for fun, let's reverse the names in MainMenuNames and see what happens:
  994.  
  995.      MainMenuNames = (NoMainMenu,SecondMenu,FirstMenu,QuitMenu);
  996.  
  997.    When you test this, you will find the two menus in different positions.  
  998.    This makes rearranging a snap.  We didn't even have to change anything 
  999.    about the MainMenu records themselves.
  1000.  
  1001.    Title - For a main menu, the title is required.  By default, the first 
  1002.    letter is used for command letter after pressing F10.  Press F10 now and 
  1003.    then press "S".  This will pull down the SecondMenu.  But what about the 
  1004.    global key Alt-S?  Press F2 to get back to the work window and try Alt-S.  
  1005.    Nothing happens.
  1006.  
  1007.    Global Key - To assign an extended key combination to this menu, go to the 
  1008.    bottom of the file to the section called Check Global Keys.  In this code, 
  1009.    an assignment can be made for this menu.  Insert the following line into 
  1010.    the code:
  1011.  
  1012.  
  1013.  
  1014.  
  1015.  
  1016.    Chapter 3, Programming Menus                                        Page 17
  1017.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  1018.  
  1019.  
  1020.      ...
  1021.      AltF: SetCmdSeq ('F');
  1022.      AltS: SetCmdSeq ('S');   { insert this line }
  1023.      AltQ: SetCmdSeq ('Q');
  1024.      ...
  1025.  
  1026.    This is part of a case statement, so the order is not important.  In 
  1027.    addition, a value must be assigned to the constant AltS.  Back up a few 
  1028.    lines and add:
  1029.  
  1030.      ...
  1031.      AltF = #33;
  1032.      AltS = #31;  { insert this line }
  1033.      AltQ = #45;
  1034.      ...
  1035.  
  1036.    Now run the code and try Alt-S again to find that it now works.  But what 
  1037.    did we just do?  Any time an extended key is pressed at the keyboard, the 
  1038.    program always passes through the procedure called CheckGlobalKeys.  If the 
  1039.    extended keycode matches one in the case statement, the program sets a 
  1040.    sequence of normal key codes that would be pressed just as if pressing F10 
  1041.    and then "S".  The keycode constant can be referenced in Appendix C of the 
  1042.    TP5 reference manual.
  1043.  
  1044.  
  1045.    ADDING SUBMENUS
  1046.  
  1047.    Every menu can pull down another submenu.  This section will show how to 
  1048.    include one.  The method is much the same as with main menus.
  1049.  
  1050.  
  1051.    Submenu Name - Also at the beginning of PULLSTAT.PAS is an enumerated type 
  1052.    called SubMenuNames which looks like:
  1053.  
  1054.      SubMenuNames = (NoSubMenu,MySubMenu);
  1055.  
  1056.    Let's go ahead and use the name MySubMenu.
  1057.  
  1058.    Submenu Record - Just after the main menu record QuitMenu is an area for 
  1059.    submenus.  There is already a record made for MySubMenu and looks like the 
  1060.    following:
  1061.  
  1062.      GetSubMenu (MySubMenu);
  1063.      MenuMode := SingleChoice;
  1064.      SingleFlagLine := 5;
  1065.      Line[1] := '1 line';
  1066.      Line[2] := '2 line';
  1067.      Line[3] := '3 line';
  1068.      Line[4] := '4 line';
  1069.      MsgLineNum  := ord(SubML);
  1070.      HelpWndwNum := ord(SubMenuHW);
  1071.      SaveSubMenu;
  1072.  
  1073.    It is exactly like the main menu record, except to get and save it, 
  1074.    GetSubMenu and SaveSubMenu are used.  A title is not required for a 
  1075.  
  1076.  
  1077.    Chapter 3, Programming Menus                                        Page 18
  1078.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  1079.  
  1080.  
  1081.    submenu as InitPull automatically gives it the name of the parent menu.  
  1082.    Now let's link the submenu to a main menu.
  1083.  
  1084.    Linking Menus - Choose SecondMenu line 2 for the line where MySubMenu is to 
  1085.    be linked.  In the SecondMenu (not the submenu) record, modify line 2 to 
  1086.    the following code:
  1087.  
  1088.      ...
  1089.      Title   := 'Second';
  1090.      Line[1] := 'A2 line';
  1091.      Line[2] := 'B2 line';  LineMode[2] := ToSubMenu;  
  1092.                             LinkNum [2] := ord(MySubMenu);
  1093.      ...
  1094.  
  1095.    Run the code and see that the submenu is pulled down when you press RETURN 
  1096.    on line 2 of SecondMenu.  This is probably simpler than you thought!  You 
  1097.    can also see a three-bar symbol on this line which indicates the line is 
  1098.    linked to a submenu.  By setting the line mode to ToSubMenu, the program is 
  1099.    prepared to pull-down another menu.  LinkNum identifies the record to be 
  1100.    pulled which is MySubMenu.  LinkNum is a byte type so using Ord is 
  1101.    required.
  1102.  
  1103.    Linking Configuration - The submenus link in a slide-up rather than a 
  1104.    slide-under configuration.  Menus grow vertically as the list expands.  If 
  1105.    the list gets too long, it can slide up when it hits the bottom of the 
  1106.    screen.  This leaves both the main menu and submenu in full view.  In 
  1107.    contrast, the data windows, which are covered later, use the slide-under 
  1108.    configuration.
  1109.  
  1110.    Default Linking Direction - Most Submenu are linked to the main menu in a 
  1111.    right-preferred arrangement.  When menus get crowded to the right, InitPull 
  1112.    will automatically reverse to the left and all dot and 3-bar symbols will 
  1113.    also appear on the left.  Each subequent Submenu will continue to link in 
  1114.    the same direction as its parent as far as it can.
  1115.  
  1116.    Manual Linking Direction - As long as LinkDir is not specified like in our 
  1117.    example, InitPull will configure it for you.  However, this may not be 
  1118.    preferred in all cases.  To specify it manually, set the value of LinkDir 
  1119.    in that menu record to Left or Right which forces all submenus to be linked 
  1120.    in that direction.
  1121.  
  1122.    Global Key - Suppose this is a frequently used submenu and we want to 
  1123.    assign an extended key, say Alt-M, to access it.  To do this, it is much 
  1124.    the same as with a main menu, except there is an additional keystroke.  Add 
  1125.    the following line to CheckGlobalKeys:
  1126.  
  1127.      AltM: SetCmdSeq ('SB');
  1128.  
  1129.    and include a value for the constant Alt-M:
  1130.  
  1131.      AltM = #50;  { the Alt-M  extended key code }
  1132.  
  1133.    When you run the program, pressing Alt-M will pull down both SecondMenu and 
  1134.    MySubMenu just as if you had sequentially pressed F10, "S" and "B".
  1135.  
  1136.  
  1137.  
  1138.    Chapter 3, Programming Menus                                        Page 19
  1139.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  1140.  
  1141.  
  1142.    SetCmdSeq - PULL saves the sequence of keystrokes for the current menu 
  1143.    level in a global string variable called CmdSeq.  SetCmdSeq compares the 
  1144.    current location of CmdSeq with the new destination and sets two variables 
  1145.    for the shortest path - MoreCmdSeq and PopLevels.  This will be covered 
  1146.    later in detail under the Control Flags section.
  1147.  
  1148.    SubSubmenus - SubSubmenus can be added in just the same way as submenus.  
  1149.    In fact you could nest them as deep as you want.  InitPull expects the 
  1150.    record names in SubMenuNames to be in a certain order so it can properly 
  1151.    locate each one on the CRT.  Just be sure that the order is all Submenus 
  1152.    first, all SubSub-menus second, all SubSubSubmenus third, etc.
  1153.  
  1154.  
  1155.    HELP MESSAGES
  1156.  
  1157.    Each menu has a help message that is displayed on the last line of the CRT 
  1158.    where the application can indicate valid keys and status or error messages.  
  1159.    In this section, you will discover how these messages can be linked to any 
  1160.    menu while it is displayed.
  1161.  
  1162.  
  1163.    Reserved Messages - PULL has already included some predefined messages for 
  1164.    several contexts including those for main menus and submenus.  In 
  1165.    PULLSTAT.PAS, just below the last submenu record, you can find an array of 
  1166.    MsgLines.  The ones reserved for main menus and submenus are MainML and 
  1167.    SubML, respectively:
  1168.  
  1169.      MsgLine[ord(MainML)]:=' F1-help  F2-pop   LTR-cmd  ESC-return  '+
  1170.                            '        '^[^Z' menus  '^X^Y'-hilight  CR-select';
  1171.      MsgLine[ord(SubML)] :=' F1-help  F2-pop   LTR-cmd  ESC-return  '+
  1172.                            '                  '^X^Y'-hilight  CR-select';
  1173.  
  1174.    The concatenation is just so that it will fit within an 80 column width in 
  1175.    the source code.  Back at the top of the file, you can find the enumerated 
  1176.    type MsgLineNames that helps identify each message.  All the messages up to 
  1177.    HelpML are reserved as PULL expects them to be in that order.  But new ones 
  1178.    can be added.
  1179.  
  1180.    New Messages - To create a new message, just append a name in the 
  1181.    MsgLineNames type and write out your new message.  Let's try it on the Quit 
  1182.    menu by changing MsgLineNum in its menu record as follows:
  1183.  
  1184.      ...
  1185.      Line[2] := 'Quit';      ProcPtr[2] := @SetQuit;
  1186.      BackToDefault := true;
  1187.      MsgLineNum := ord(QuitML);
  1188.      ...
  1189.  
  1190.    Then append the name QuitML to the end of MsgLineNames:
  1191.  
  1192.      MsgLineNames = (NoML,WorkML,TopML,AltML,MainML,SubML,DW_ML,DE_ML,
  1193.                      SeqML,HelpML,ProcML,QuitML);
  1194.  
  1195.    And finally, let's create the message itself:
  1196.  
  1197.  
  1198.  
  1199.    Chapter 3, Programming Menus                                        Page 20
  1200.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  1201.  
  1202.  
  1203.      MsgLine[ord(QuitML)] := ' Press "Q" if you are sure you want to quit.';
  1204.  
  1205.    Short messages are no problem, because PULL will clear the rest of the 
  1206.    message line.  Run the program now and see that the new message appears 
  1207.    when the Quit menu is pulled.  By now, you are seeing that pull-down menus 
  1208.    can link other menus and messages quite easily.
  1209.  
  1210.    Alt Key Message - You may have noticed when you hold down the Alt for more 
  1211.    than a half second, a message appears for the possible combinations.  When 
  1212.    we created a submenu with global key access, it is not likely a first-time 
  1213.    user would know the key was available.  The AltML message is reserved for 
  1214.    this purpose.  Let's alter the line to:
  1215.  
  1216.      MsgLine[ord(AltML)] :=' Alt: F-First  M-MySubMenu              '+
  1217.                            '                                 X-Exit';
  1218.  
  1219.    Run the program and hold down the Alt key to test the new message.
  1220.  
  1221.  
  1222.    HELP WINDOWS
  1223.  
  1224.    Many times the help message is not enough to fully explain the options 
  1225.    available for the context.  In this section, you will discover how to 
  1226.    create context-sensitive help windows and apply them to the menus.
  1227.  
  1228.  
  1229.    Help Window Record - Just as each menu has its own record, each Help Window 
  1230.    also has one called HelpWndw.  There are only a couple of variables that 
  1231.    need adjustment, to link in the number of lines to be included in the 
  1232.    window.  Let's try creating a help window for a main menu.  
  1233.  
  1234.    Example Window - Run the current example program again and test the F1 
  1235.    key while the SecondMenu is pulled down.  You should see a two-line help 
  1236.    window with the message "Main menu help message".  So, some help window is 
  1237.    already there, but the message is just bare bones.  Let's find out how the 
  1238.    message got there and alter it.
  1239.  
  1240.    Help Lines - In PULLSTAT.PAS after the MsgLine messages, there is another 
  1241.    section for setting HelpLines.  You should be able to see the code:
  1242.  
  1243.      HelpLine[ord(HLm1)]:='Main menu help message';
  1244.      HelpLine[ord(HLmL)]:='';
  1245.  
  1246.    These are the actual messages you saw in the help window.  Each window can 
  1247.    have a variable number of lines in the help window.  The program will 
  1248.    automatically size the window to fit in all the lines.  Let's edit and add 
  1249.    an extra line:
  1250.  
  1251.      HelpLine[ord(HLm1)]:='Main menu help message';
  1252.      HelpLine[ord(HLm2)]:='Press RETURN on the highlighted line to make';
  1253.      HelpLine[ord(HLmL)]:='your selection.';
  1254.  
  1255.    Since a new HelpLine name, HLm2, has been added, it must be inserted in the 
  1256.    enumerated type HelpLineNames at the top of the file:
  1257.  
  1258.  
  1259.  
  1260.    Chapter 3, Programming Menus                                        Page 21
  1261.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  1262.  
  1263.  
  1264.      ...
  1265.      HLt1,HLtL,        { Top Line Menu }
  1266.      HLm1,HLm2,HLmL,   { Main menu }        { Modify this line. }
  1267.      HLs1,HLsL         { Submenu }
  1268.      ...
  1269.  
  1270.    Now run the program and test the modified help window.  This time you 
  1271.    should see the three lines.  With just a couple of changes, all help 
  1272.    windows are still in order along with the contents because it is so easy to 
  1273.    work with names instead of numbers.  How did the program know how many 
  1274.    lines to display even though changes were made?
  1275.  
  1276.    Number of Help Lines - In the section just below the HelpLines, see the 
  1277.    following code:
  1278.  
  1279.      ...
  1280.      HelpMsgLineNum := ord(HelpML);     { Standard message for a Help window }
  1281.      SetHelpLines (WorkWndwHW,HLw1,HLwL);
  1282.      SetHelpLines (TopMenuHW ,HLt1,HLtL);
  1283.      SetHelpLines (MainMenuHW,HLm1,HLmL);
  1284.      ...
  1285.  
  1286.    The call to SetHelpLines is a trivial procedure listed earlier in the code 
  1287.    that simply sets the first and last line number into the help window record 
  1288.    by using HelpLineNames.  Notice that the first and last line names end with 
  1289.    1 and L respectively.  This makes it handy so these statements never need 
  1290.    to be altered when new lines are added or inserted.
  1291.  
  1292.    Help Window Names - The window name is MainMenuHW which in listed the 
  1293.    enumerated type HelpWndwNames at the beginning of PULLSTAT.PAS:
  1294.  
  1295.      HelpWndwNames = (NoHW,WorkWndwHW,TopMenuHW,MainMenuHW,SubMenuHW,
  1296.                       DataWndwHW);
  1297.  
  1298.    Help Window Record - A help window record is assigned to each one of these 
  1299.    names.  In the SecondMenu record, we can find the window record name by 
  1300.    examining the following:
  1301.  
  1302.      ...
  1303.      MsgLineNum  := ord(MainML);
  1304.      HelpWndwNum := ord(MainMenuHW);
  1305.      SaveMainMenu;
  1306.      ...
  1307.    
  1308.    So now we can finally see how this help window was assigned to the main 
  1309.    menu.  Rather than having a standardized help window for each main menu as 
  1310.    a whole, you can even create new ones just as new message lines were 
  1311.    created:
  1312.  
  1313.      1. Append HelpWndwNames.
  1314.      2. Append HelpLineNames.
  1315.      3. Make HelpLine assignments.
  1316.      4. Use SetHelpLines to identify the first and last help lines.
  1317.      5. Assign the HelpWndwNum to the menu record.
  1318.  
  1319.  
  1320.  
  1321.    Chapter 3, Programming Menus                                        Page 22
  1322.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  1323.  
  1324.  
  1325.    Help Message - Even the help window needs a help message.  One has already 
  1326.    been standardized for you called HelpML.  InitPull will initialize all help 
  1327.    windows to be assigned the message number in HelpMsgLineNum.
  1328.  
  1329.    Window Width - All help windows have a standard width which is set by a 
  1330.    configuration constant in P5X-VAR.INC called HelpCharsPerLine currently 
  1331.    set at 50.  The program adds 2 to this value to leave a space between the 
  1332.    left and right borders.  The value can only be changed with the source 
  1333.    code.
  1334.  
  1335.    No Help Window - If there are selected records where a help window is not 
  1336.    wanted, just set:
  1337.  
  1338.      HelpWndwNum := NoHW;
  1339.  
  1340.    Integrated Help Windows - This system will integrate the help windows into 
  1341.    the EXE file.  With enumerated names, up to 255 lines can be included.  If 
  1342.    you need more, it is suggested that you develop a disk-based help system 
  1343.    which is currently beyond the scope of the this utility.
  1344.  
  1345.  
  1346.    DEFAULT ATTRIBUTES
  1347.  
  1348.    This section will show the variables used to create default attributes for 
  1349.    menus, windows and messages.
  1350.  
  1351.  
  1352.    InitPull - At the very first of the procedure GetUserPullStats, several 
  1353.    default attribute variables can be given assignments.  For instance, 
  1354.    MainMenuWattr will be used by InitPull to give all main menus the same 
  1355.    window attribute for Wattr in the menu record.  This saves you from having 
  1356.    to make the same assignment to every menu record.
  1357.  
  1358.    Attributes - As a personal preference, many users prefer the screen to have 
  1359.    different attribute when possible.  The following is the list of default 
  1360.    attributes and what they affect:
  1361.  
  1362.                        Record
  1363.      Default variable  Variable   Description
  1364.      ----------------  ---------  ------------------------------------------
  1365.      TopLineMenuAttr   n/a        Full length of the top line menu.
  1366.      TopLineMenuHattr  n/a        Top line menu HiLite.
  1367.      TopLineMenuLattr  n/a        Top line menu command Letter.
  1368.  
  1369.      MainMenuWattr     Wattr      Main menu Window.
  1370.      MainMenuBattr     Battr      Main menu Border.
  1371.      MainMenuHattr     Hattr      Main menu HiLite.
  1372.      MainMenuLattr     Lattr      Main menu command Letter.
  1373.      MainMenuCattr     Cattr      Main menu Comment line.
  1374.  
  1375.      SubMenuWattr      Wattr      Sub menu Window.        
  1376.      SubMenuBattr      Battr      Sub menu Border.        
  1377.      SubMenuHattr      Hattr      Sub menu HiLite.        
  1378.      SubMenuLattr      Lattr      Sub menu command Letter.
  1379.      SubMenuCattr      Cattr      Sub menu Comment line.
  1380.  
  1381.  
  1382.    Chapter 3, Programming Menus                                        Page 23
  1383.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  1384.  
  1385.  
  1386.      
  1387.      HelpWndwWattr     Wattr      Help Window Window.
  1388.      HelpWndwBattr     Battr      Help Window Border.
  1389.  
  1390.      MsgLineAttr       n/a        Message line full length.
  1391.      ErrMsgAttr        n/a        Error messages.
  1392.      KeyStatusAttr     n/a        Key status of NumLock, Caps, and ScrollLock.
  1393.  
  1394.    Find the variable MainMenuBattr and modify it to inverse video:
  1395.  
  1396.      MainMenuBattr := LightGrayBG;
  1397.  
  1398.    When you run the program, you will find that every main menu has this new 
  1399.    attribute.  All the other variables work similarly.
  1400.  
  1401.    Mono vs. Color - You probably noticed an "if" statement in the code testing 
  1402.    the current video mode.  The results of this test allows you to configure 
  1403.    the menus for either Monochrome or color monitors.  Refer to your technical 
  1404.    reference manual for the effects of one attribute on either monitor.
  1405.  
  1406.  
  1407.    DEFAULT BORDERS
  1408.  
  1409.    This section will show the variables used to create default border styles 
  1410.    for the menus and windows just like the attributes mentioned above.
  1411.  
  1412.  
  1413.    Border Styles - The following is a list of default border style variables 
  1414.    and what they affect:
  1415.  
  1416.                        Record
  1417.      Default variable  Variable   Description
  1418.      ----------------  ---------  -----------------
  1419.      MainMenuBrdr      Border     All main menus.
  1420.      SubMenuBrdr       Border     All submenus.
  1421.      HelpWndwBrdr      Border     All help windows.
  1422.  
  1423.    The shell program has assigned MainMenuBrdr to a custom border UserBrdr1.  
  1424.    Let's modify this to SingleBrdr:
  1425.  
  1426.      MainMenuBrdr := SingleBrdr;
  1427.  
  1428.    In addition, you can optionally comment out the assignment of UserBrdr1 in 
  1429.    the previous line since it is no longer needed.  When the program is run, 
  1430.    all main menus will now have a single-line border style including the 
  1431.    partitions.
  1432.  
  1433.  
  1434.    CONTROL FLAGS
  1435.  
  1436.    The pull-down menus can be programmably controlled in your program by 
  1437.    toggling various pull-down control flags.  This helps direct the users to 
  1438.    the needed menus automatically instead of manually pressing a key sequence.  
  1439.    In this section, you will discover these flags and what they control.  Save 
  1440.    the shell program now for later use and get back to PULLDEMO for this 
  1441.  
  1442.  
  1443.    Chapter 3, Programming Menus                                        Page 24
  1444.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  1445.  
  1446.  
  1447.    section.
  1448.  
  1449.    Control Variables - Here is the list of variables that control the menus:
  1450.  
  1451.      PopToWorkWndw - (Type: boolean) if true, all menus are removed and 
  1452.                      control is returned to the work window.
  1453.      PopToTop      - (Type: boolean) if true, control is set to the Top Line 
  1454.                      menu.
  1455.      PopLevels     - (Type: byte) number of levels (or menus) to pop.
  1456.      Popped        - (function) pops all menus before execution of ExecPtr.
  1457.      MoreCmdSeq    - (Type: string) series of command letters to do after 
  1458.                      popping.
  1459.      PullDown      - (Type: boolean) if true, the menus will be pulled down 
  1460.                      according to MoreCmdSeq.
  1461.  
  1462.    Examples - Run PULLDEMO and access Alt-I/Update.  In the Update menu, there 
  1463.    are six examples of how the menus can be controlled in combination with 
  1464.    executing a ProcPtr.  Execute each of those six lines to see what they do.  
  1465.    In PULLSTAT.PAS, search for "GetSubMenu (UpdateMenu)" and see that each 
  1466.    line is executing ProcPtr in the menu, so let's find out what those 
  1467.    procedures are doing.
  1468.  
  1469.    Process Then Pop - Back up until you find the ProcessThenPop procedure.  
  1470.    Very simply, the program first executed DummyProc and then set 
  1471.    PopToWorkWndw true.  When the flow of execution passes back through the key 
  1472.    dispatcher, PULL will immediately pop all menus and return to the top work 
  1473.    window.
  1474.  
  1475.    Pop Then Process - But suppose we want to do the reverse.  Anytime ProcPtr 
  1476.    is used for execution, a copy of it is kept in the global variable ExecPtr.  
  1477.    By using Popped, the function sets the appropriate flags to pop the menus.  
  1478.    The first time Popped is tested, it is false.  So, DummyProc is not 
  1479.    executed.  Once the menus are popped back to the work window, PULL executes 
  1480.    ProcPtr again via ExecPtr.  This time Popped will be true and DummyProc 
  1481.    will be executed.
  1482.  
  1483.    Pop, Process, and Pull - Let's go one step further and pull the same menus 
  1484.    back down that were popped.  Looking few lines down further in the 
  1485.    PopProcessAndPull procedure, the new line that was added is setting 
  1486.    PullDown to true.  But how does the program know what menus to pull?  PULL 
  1487.    keeps a copy of the last command sequence in the string MoreCmdSeq.  When 
  1488.    PullDown is true, the menus are pulled down by MoreCmdSeq.  This is useful 
  1489.    when there is something under the menus that needs to be changed like 
  1490.    accessing another work window.
  1491.  
  1492.    Popping Levels - Or, if you just want to back up a number of menu levels, 
  1493.    just specify the number of levels to pop with PopLevels.  In the procedure 
  1494.    PopNumOfLevels, rather than making the menu completely disappear only to 
  1495.    needlessly pull them back down again, this procedure pops back as far as it 
  1496.    needs to go and then additionally pulls down another submenu (or data 
  1497.    window).  This sequence is useful when you know exactly where you are and 
  1498.    where you are going.
  1499.  
  1500.    Popping to New Menus - If you need to go to a new menu, you can use the 
  1501.    flag PopToTop which will pop the menus up to the Top Line.  By setting 
  1502.  
  1503.  
  1504.    Chapter 3, Programming Menus                                        Page 25
  1505.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  1506.  
  1507.  
  1508.    PullDown true and MoreCmdSeq to the desired menu, you can get to the new 
  1509.    destination like the procedure PopToNewMenu.
  1510.  
  1511.    Smart Pop and Pull - But suppose the menus will execute the same ProcPtr 
  1512.    from three different locations in the menus, and still want it to appear 
  1513.    smart like PopNumOfLevels does?  PULL has a procedure called SetCmdSeq that 
  1514.    compares the current location, CmdSeq, with your destination.  It sets 
  1515.    MoreCmdSeq and PopLevels to the shortest path.  In fact, PopNumOfLevels 
  1516.    could have looked like:
  1517.  
  1518.      procedure PopNumOfLevels;
  1519.      begin
  1520.        PullDown := true;
  1521.        SetCmdSeq ('IY');
  1522.      end;
  1523.  
  1524.    The parameter for SetCmdSeq is the full sequence of command letters to be 
  1525.    pressed from the Top Line.
  1526.  
  1527.    Sequential Data Windows - One application of these control flags may be 
  1528.    sequential entry for data windows.  Access Alt-I/Date and press RETURN a 
  1529.    few times to see how the menus are cycled in a loop for the date.  To see 
  1530.    how it was done, follow the ProcPtrs in the DateMenu and see what flags 
  1531.    were set.
  1532.  
  1533.  
  1534.    SUMMARY
  1535.  
  1536.    At this point in the tutorial, you've been able to master the configuration 
  1537.    of the top line, main, and sub menus with all the menu modes and most of 
  1538.    the line modes.  In addition, you found how to add menus and submenus 
  1539.    and assign help messages and help windows.  You changed the appearance of 
  1540.    the menus with attributes and borders.  You could even programmably control 
  1541.    the sequence of menus that were pulled down.  These were all accomplished 
  1542.    by just filling out the appropriate variables.
  1543.  
  1544.  
  1545.  
  1546.  
  1547.  
  1548.  
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.    Chapter 3, Programming Menus                                        Page 26
  1566.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  1567.  
  1568.  
  1569.    4.  S C R E E N   D E S I G N
  1570.  
  1571.    You are now at a point where you understand most of the fundamental 
  1572.    features in PULL.  In this section, you will discover how to control the 
  1573.    arrangement of the major components of full screen design.  You will be 
  1574.    able to relocate the Status line, Top Line menu, Main menus, Work 
  1575.    window(s), and Message line.  Arrangement of the components will depend on 
  1576.    the human factors needed for your application.
  1577.  
  1578.  
  1579.    STATUS LINE
  1580.  
  1581.    The Status line is a row that you can reserve for pertinent information.  
  1582.    In the shell program, the status line is assumed to be row 1 where a 
  1583.    program name, title, and copyright were placed.  In the TP5 environment, 
  1584.    row 2 is the status line for line, column, and insert status.  Actually, 
  1585.    PULL does nothing to program this line, but PULL was designed to work 
  1586.    around it.
  1587.    
  1588.  
  1589.    TOP LINE MENU
  1590.  
  1591.    Showing the Top Line - The top line menu is automatically created by 
  1592.    assembling the titles from each main menu.  So, the string is already 
  1593.    created for you in the string variable TopLineStr.  To write this string to 
  1594.    the screen, simply call ShowTopLine.  But where is it placed?  
  1595.  
  1596.    Top Line Placement - Back in GetPullUserStat, search for the variable 
  1597.    TopLineRow.  It is found in a section called Top Line Defaults.  This is 
  1598.    the variable that determines where the top line is placed:
  1599.  
  1600.      TopLineRow := 2;     { Top Line menu to appear on row 2. }
  1601.  
  1602.    Let's try reversing the Status line and the Top line menu in the shell 
  1603.    program.  Set TopLineRow to 1 and then look in PULLSHEL.PAS and modify the 
  1604.    row of the Status line to 2:
  1605.  
  1606.      WWrite ( 2, 1,'PULLSHELL v5.Xa           Multi-level Pu'+
  1607.                    'll-down Menus       Copr 1989  J H LeMay');
  1608.  
  1609.    Now run the program and see both lines reversed, but when the main menus 
  1610.    are pulled, they are still on row 3.  How can they be moved?
  1611.  
  1612.  
  1613.    MAIN MENU ROW
  1614.  
  1615.    Main Menu Row - The row on which the main menus appear is controlled by 
  1616.    the value of MainMenuRow.  The Main menus do not have to be attached to Top 
  1617.    Line menu and can appear on any row provided they do not interfere with 
  1618.    the Message line.
  1619.  
  1620.    Moving the Row - Let's shift the Main menus back up so they will appear 
  1621.    to be attached to the Top Line menu.  In PULLSTAT.PAS, search for:
  1622.  
  1623.      MainMenuRow := 3;  { First row of main menus to appear on row 3 }
  1624.  
  1625.  
  1626.    Chapter 4, Screen Design                                            Page 27
  1627.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  1628.  
  1629.  
  1630.  
  1631.    and change it to 2.  Run the program again to see that the main menus pull-
  1632.    down now on row 2.  But also check the submenu by pressing Alt-M.  Even the 
  1633.    submenu is correctly placed!  InitPull accommodates the changes.
  1634.  
  1635.  
  1636.    SUBMENU ROW
  1637.  
  1638.    SubMenu Row - Try to arrange the lines in your menus that link submenus so 
  1639.    that they are as high in the menu as practical.  Otherwise, long menus will 
  1640.    bottom out on the CRT and PULL will be sliding up the menus to keep them in 
  1641.    view.  PULL handles this well by using the slide-up configuration, but the 
  1642.    menus will not appear to have much foresight in your design.  The 
  1643.    Alt-A/Tires/Brands menu is a good example of keeping menus high. 
  1644.  
  1645.  
  1646.    WORK WINDOWS
  1647.  
  1648.    Window Modes - The major portion of the screen is intended to be the work 
  1649.    window for your application.  This area can have one or more windows and 
  1650.    they can be in any window mode that you chose - even virtual.  Usually one 
  1651.    of the modes can be PermMode since there is no data to save under the 
  1652.    screen, but with a TSR, you may need to save the screen, too.  
  1653.  
  1654.    Window Size - The example in the shell program uses a 22x80 PermMode window 
  1655.    with border.  Let's get rid of the Status line, make the window larger, and 
  1656.    at the same time, take off the double border.  In PULLSHEL.PAS, comment out 
  1657.    the Status line with braces and modify the MakeWindow statement to the 
  1658.    following:
  1659.  
  1660.    { WWrite ( 1, 1,'PULLSHELL v5.Xa           Multi-level Pu'+
  1661.                    'll-down Menus       Copr 1989  J H LeMay'); }
  1662.      ShowTopLine;
  1663.      SetWindowModes (PermMode);
  1664.      MakeWindow (2,1,CRTrows-2,CRTcols,White+BlueBG,White+BlueBG,NoBrdr,
  1665.                  Window1);
  1666.  
  1667.    Running the program, you will see the work window took up all but the Top 
  1668.    Line menu in Row 1 and the Message line on the last row.  Notice also that 
  1669.    the contents of the window also moved because they have window-relative 
  1670.    coordinates.  This shows you the flexibility of your screen design.
  1671.  
  1672.  
  1673.    MESSAGE LINE
  1674.  
  1675.    Message Line - This is the line on which all messages will appear and is 
  1676.    usually in reference to CRTrows to accommodate different video modes.  If 
  1677.    the message line is intended to list key commands, for human factor 
  1678.    reasons, it is best to keep it near the bottom row.  
  1679.  
  1680.    Location - The location of the line is set by the variable MsgLineRow in 
  1681.    GetUserPullStats.  To whatever line it is assigned, be sure that there is 
  1682.    no possibility that it may be covered by other windows.  You may need to 
  1683.    set the window margins to do this.
  1684.  
  1685.  
  1686.  
  1687.    Chapter 4, Screen Design                                            Page 28
  1688.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  1689.  
  1690.  
  1691.  
  1692.    HELP WINDOWS
  1693.  
  1694.    There are two defaults that can be set for the Help windows - the bottom 
  1695.    row and the window modes.  This section shows how these can be modified.
  1696.  
  1697.    Bottom Row - All help windows are centered column-wise on the CRT.  
  1698.    However, the default bottom row of the window is assigned to HelpBottomRow 
  1699.    and is allowed to grow upward.  This variable is used to calculate the 
  1700.    upper left corner of the window and sets the Row and Col for each help 
  1701.    window record.
  1702.  
  1703.    Window Modes - The current example program uses a shadow with zoom effect 
  1704.    when the help window appears.  The cursor mode is also turned off.  This 
  1705.    default is assigned to HelpWndwModes which in turn assigns it to HWmodes in 
  1706.    each help window record.  
  1707.  
  1708.    Example - In the shell program, search for HelpWndwModes and modify the 
  1709.    code to the following:
  1710.  
  1711.      ...
  1712.      HelpWndwModes := CursorOffMode;
  1713.      HelpBottomRow := CRTrows-10;
  1714.      ...
  1715.  
  1716.    When you test any help window this time, the window will appear instantly 
  1717.    without the zoom effect and is placed higher from the bottom.
  1718.  
  1719.  
  1720.    START-UP MENU
  1721.  
  1722.    Control Variables - When the program first starts, you can also have the 
  1723.    program pull down any menu using the Top Line variables MPulled, PullDown, 
  1724.    and MoreCmdSeq.  Search again for TopMenuRow and see this code:
  1725.  
  1726.      TopMenuRow := 1;
  1727.      MPulled    := ord(FirstMenu);
  1728.      MoreCmdSeq := 'F';
  1729.      PullDown   := false;
  1730.  
  1731.    MPulled - This is initial assignment for the main menu title that would be 
  1732.    highlighted when pressing F10 for the first time.
  1733.  
  1734.    MoreCmdSeq - This is the actual variable that is set by the global key 
  1735.    routine SetCmdSeq.  When F2 is pressed for the first time, it would emulate 
  1736.    pressing F10 and "F" from the keyboard as if it remembered the last 
  1737.    sequence of keystrokes.  MoreCmdSeq can have as many characters as needed 
  1738.    to get down to the desired menu or window.  It is a good practice to make 
  1739.    sure the first character matches the MPulled menu.
  1740.  
  1741.    PullDown - If this is true, the program will pull-down the menus just as if 
  1742.    F2 had been pressed so that the menus pulled match the sequence in 
  1743.    MoreCmdSeq.  Try setting PullDown to true and see if FirstMenu is indeed 
  1744.    pulled.
  1745.  
  1746.  
  1747.  
  1748.    Chapter 4, Screen Design                                            Page 29
  1749.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  1750.  
  1751.  
  1752.  
  1753.    OVERRIDING DEFAULTS
  1754.  
  1755.    PULL configures almost everything automatically, but sometimes things don't 
  1756.    always fit the mold.  This section will show you how to override the 
  1757.    settings before and after PULL has configured them.
  1758.  
  1759.  
  1760.    GetUserPullStats - Row/Col locations for submenus are located by default at 
  1761.    run time with the slide-up configuration when these values remain zero, and 
  1762.    likewise DWrow/DWcol for data windows for slide-under.  You can override 
  1763.    PULL and locate them absolutely by giving them non-zero values in the 
  1764.    procedure GetUserPullStats.
  1765.  
  1766.    Submenu Location - If submenus are unusually wide and will not fit in the 
  1767.    slide-up configuration, PULL will terminate the program with a warning 
  1768.    message to let you know of the problem.  If you set the variable 
  1769.    LocationWarning false in GetUserPullStats, you can go ahead and test all 
  1770.    submenus to see the one not fitting the slide-up configuration.  PULL will 
  1771.    attempt slide-under as a second best.  If it still doesn't fit, then you 
  1772.    need an override for the Row and Col setting.  If you are satisfied with 
  1773.    the menu locations, you can optionally set LocationWarning false.  But be 
  1774.    sure to check all the menus on the CRT to make sure they have been properly 
  1775.    placed.
  1776.  
  1777.    GetOverrideStats - This procedure in PULLSTAT is executed after all the 
  1778.    automatic configuration has been done.  If there are exceptions in your 
  1779.    program, you can assign them inside this procedure.  For just a few 
  1780.    changes, you can edit the records right in the heap.  Take a look at this 
  1781.    procedure in PULLSTAT for PULLDEMO.  What kind of things would you 
  1782.    typically change?
  1783.  
  1784.    Menu Command Letters - Not all menus use the first letter for the command 
  1785.    letter.  What happens when two lines start with the same one?  Only the 
  1786.    first one will ever be reached.  So, the command letters must be changed.  
  1787.    The variable in the menu record that contains these letter is CmdLtrs.  For 
  1788.    instance, the command letters for FirstMenu are 'ABCD' where character one 
  1789.    corresponds to line 1, etc.  They are always upper case in this string, but 
  1790.    can be lower case in the menu.  So, you can edit this string to whatever 
  1791.    your command letters need to be.  In addition, that letter will also be 
  1792.    highlighted in the menu.  Inaccessible line modes like Comment and 
  1793.    Partition replace the command letter with #00.
  1794.  
  1795.    Top Line Command Letters - You can also do the same with the Top Line 
  1796.    command letters which are kept in a global variable called TopCmdLtrs.
  1797.  
  1798.    Attributes and Borders - Sometimes the default attributes and borders need 
  1799.    to be changed in a place or two.  GetOverrideStats is the place to make 
  1800.    those changes.
  1801.  
  1802.  
  1803.    SUMMARY
  1804.  
  1805.    If you have completed the tutorial with the shell program up to this point, 
  1806.    you should now have enough confidence with the major components of screen 
  1807.  
  1808.  
  1809.    Chapter 4, Screen Design                                            Page 30
  1810.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  1811.  
  1812.  
  1813.    design.  You can now develop a concept for your application that can best 
  1814.    be suited the needs of your users.  If you would like to stop now, save the 
  1815.    shell program so that it can to be used later in the following sections.
  1816.  
  1817.  
  1818.  
  1819.  
  1820.  
  1821.  
  1822.  
  1823.  
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853.  
  1854.  
  1855.  
  1856.  
  1857.  
  1858.  
  1859.  
  1860.  
  1861.  
  1862.  
  1863.  
  1864.  
  1865.  
  1866.  
  1867.  
  1868.  
  1869.  
  1870.    Chapter 4, Screen Design                                            Page 31
  1871.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  1872.  
  1873.  
  1874.    5.  D A T A   W I N D O W S
  1875.  
  1876.    Often when a menu line is selected from a menu, a means is needed to enter 
  1877.    data into the application such as numbers or file names.  PULL already has 
  1878.    powerful utilities to do this for free-field data entry including flex 
  1879.    fields, set checking, key translation, and range checking for nine types of 
  1880.    data.
  1881.  
  1882.  
  1883.    DATA WINDOW PARTS
  1884.  
  1885.    There are two parts to a data entry window - the data entry field and the 
  1886.    window.
  1887.  
  1888.    Data Entry Field - As the name implies, this is the place where characters 
  1889.    are allowed to be entered for the data.  This is also called entry or field 
  1890.    for short.
  1891.  
  1892.    Data Window - The window is the border and spacing surrounding the field.  
  1893.    Using the term data window loosely refers to both the field and the window 
  1894.    together.
  1895.  
  1896.  
  1897.    DATA WINDOW RECORD
  1898.  
  1899.    The arrangement of the records for data windows is very similar to the way 
  1900.    menu records have been done.  So, the same concept of fill-in-the-blank is 
  1901.    used.  In this section, you will find how these records can be filled out 
  1902.    in the program.
  1903.  
  1904.  
  1905.    Top Data Window - Let's find the data window record and see what it 
  1906.    contains:
  1907.  
  1908.      1. Load the file PULLDATA.PAS into the TP editor.
  1909.      2. Set PULLSHEL.PAS to be the Primary file.
  1910.      3. Search for "with TopDataWndw"
  1911.      4. See the following code:
  1912.  
  1913.          GetDataWndw (ord(aByteDW));         { Just gets cleared DataWndw }
  1914.          VarAddr       := @aByte;
  1915.        { TypeOfData    := Bytes; }           { This is the default }
  1916.          Field         := 3;
  1917.        { MsgLineNum    := ord(DW_ML); }      { This is the default }
  1918.        { HelpWndwNum   := ord(DataWndwHW); } { This is the default }
  1919.          SaveDataWndw;                       { Saves it in the heap }
  1920.  
  1921.    In the tutorial program of PULLSHEL.PAS, the program does not have any data 
  1922.    windows linked to the menus yet, but this record has already been written 
  1923.    to speed things along.  As you can see, only four lines were needed to be 
  1924.    set in the Data Window record which is named aByteDW.  Let's go ahead and 
  1925.    link this record into one of the menus.
  1926.  
  1927.    Linking Data Windows - Go back to PULLSTAT.PAS to find the FirstMenu record 
  1928.    and revise it to add this data window to line 3:
  1929.  
  1930.  
  1931.    Chapter 5, Data Windows                                             Page 32
  1932.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  1933.  
  1934.  
  1935.  
  1936.      GetMainMenu (FirstMenu);
  1937.      ...
  1938.      Line[1] := 'A line';
  1939.      Line[2] := 'B line';
  1940.      Line[3] := 'Enter Byte';  LineMode[3] := ToDataWndw;  
  1941.                                LinkNum [3] := ord(aByteDW);
  1942.      Line[4] := 'D line';
  1943.      ...
  1944.  
  1945.    When the program is run, pressing RETURN on line 3 will pull-down the data 
  1946.    entry window.  The variable is a byte type which it was assigned by default 
  1947.    in the data window record.  Go ahead and experiment with the entry by 
  1948.    making mistakes such as a number over 255.  When you get an error message, 
  1949.    just press ESC.  For the full list of editing keys, press F1 for the help 
  1950.    window.
  1951.  
  1952.    Window Location - Notice that the location of the window is immediately 
  1953.    underneath the HiLite and shifted slightly to the right.  This is called a 
  1954.    slide-under configuration.  Since there is only one row in a Data Window, 
  1955.    they tend to grow horizontally.   Should the window be too long for the 
  1956.    right side of the screen, the window would then slide under the HiLite to 
  1957.    the left until it fit.  This location is determined at run time.  
  1958.  
  1959.    Justification - The entry is always left justified since it is an input-
  1960.    only window.
  1961.  
  1962.    Line Mode - If you remember about line modes, we did not get a chance to 
  1963.    test ToDataWndw.  So, now you can see that this instructs PULL that a Data 
  1964.    Window is linked to the menu and it then uses the named data window record 
  1965.    for the window.
  1966.  
  1967.    Link Number - The number of the Data Window record linked is of course the 
  1968.    value of the name aByteDW.  Again, names are used to easily arrange and 
  1969.    identify the contents of the record.  So, how is the name assigned?
  1970.  
  1971.    Data Window Names - At the top of the file PULLSTAT.PAS (not PULLDATA.PAS), 
  1972.    the enumerated type DataWndwNames has the following list:
  1973.  
  1974.      DataWndwNames = (NoDW,aByteDW);
  1975.  
  1976.    Only one window name has been assigned and that is the one being tested.  
  1977.    There are no reserved names except NoDW since the window numbers are 1-
  1978.    based.  Notice that PULLDATA uses PULLSTAT.  Since DataWndwNames is in the 
  1979.    interface, the names can also be used in PULLDATA.  Ok, the data is plugged 
  1980.    into the window, but where is it being stored?
  1981.  
  1982.  
  1983.    DATA WINDOW VARIABLE
  1984.  
  1985.    Variable Address - To know where the variable is located, the record uses a 
  1986.    pointer to the variable location.  The variable used in this window is 
  1987.    aByte which is a typed constant declared at the beginning of PULLDATA.PAS 
  1988.    and given a value of 100.  To get the address of the variable, you just 
  1989.    place the "@" operator in front of the variable and it returns its FAR 
  1990.  
  1991.  
  1992.    Chapter 5, Data Windows                                             Page 33
  1993.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  1994.  
  1995.  
  1996.    address.
  1997.  
  1998.    Type of Data - Because a pointer is being used instead of the variable 
  1999.    itself, it is not known how many bytes the variable uses in memory and 
  2000.    neither is the type of data.  So, PULL must be instructed what type of data 
  2001.    is being accessed.  PULL can handle nine types of data which is enumerated 
  2002.    in P5X-VAR.INC:
  2003.  
  2004.      TypeOfDataType = (Bytes,Words,ShortInts,Integers,LongInts,Reals,UserNums,
  2005.                        Chars,Strings);
  2006.  
  2007.    The associated data types should be intuitive.  A special case is UserNums 
  2008.    which are really strings, but are meant to be displayed as numbers like hex 
  2009.    for example.  Remembering that all zero values in the record are the 
  2010.    default, now you can see why TypeOfData defaulted to Bytes when nothing was 
  2011.    assigned - good ol' fill-in-the-blank again.
  2012.  
  2013.    Matching the Type - Pascal has strong type checking and it can spoil you 
  2014.    easily.  This arrangement of splitting the variable into a type and a 
  2015.    pointer is most convenient for the Data Window.  However, it is up to your 
  2016.    skills as a programmer to ensure that the type truly matches the data at 
  2017.    that destination as PULL both reads and writes to it.
  2018.  
  2019.    Validity Check - All numeric types are given a validity check by using the 
  2020.    Val procedure.  If the data entry can successfully be converted to the 
  2021.    specified numeric type and without overflow, the data is considered valid.  
  2022.    If not, the error message "Invalid entry." is displayed.  For now, here is 
  2023.    a hint about error messages.  You can see the string for this message 
  2024.    earlier in the file:
  2025.  
  2026.      ErrMsgLine[ord(InvalidEM)]:=' Invalid entry.           ESC-acknowledge';
  2027.  
  2028.  
  2029.    FIELDS
  2030.  
  2031.    This section gives instructions on how to adjust the field sizes for the 
  2032.    data entry window.
  2033.  
  2034.    Field - Let's see how easy it to add a new data window on our own for 
  2035.    strings and adjust the field sizes.  Right after the aByteDW record, add 
  2036.    the following new record:
  2037.  
  2038.      GetDataWndw (ord(MyStringDW));
  2039.      VarAddr       := @MyString;
  2040.      TypeOfData    := Strings;
  2041.      Field         := 25;
  2042.      SaveDataWndw;
  2043.  
  2044.    At the top of the file, declare the constant MyString:
  2045.  
  2046.      ...
  2047.      aByte2: byte = 200;
  2048.      MyString: string[25] = 'This is my string.';
  2049.  
  2050.    Now let's link it into line 4 of the FirstMenu.  So, in PULLSTAT, modify 
  2051.  
  2052.  
  2053.    Chapter 5, Data Windows                                             Page 34
  2054.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  2055.  
  2056.  
  2057.    the FirstMenu record to:
  2058.  
  2059.      GetMainMenu (FirstMenu);
  2060.      ...
  2061.      Line[1] := 'A line';
  2062.      Line[2] := 'B line';
  2063.      Line[3] := 'Enter Byte';  LineMode[3] := ToDataWndw;  
  2064.                                LinkNum [3] := ord(aByteDW);
  2065.      Line[4] := 'My string';   LineMode[4] := ToDataWndw;
  2066.                                LinkNum [4] := ord(MyStringDW);
  2067.      ...
  2068.      
  2069.    And let's not forget to add MyStringDW to the DataWndwNames type:
  2070.  
  2071.      DataWndwNames = (NoDW,aByteDW,MyStringDW);
  2072.  
  2073.    Run the program and test the data window.  Since Field was set to 25, the 
  2074.    window was expanded to allow a 25 character entry with a space on either 
  2075.    side.  So, whatever the field width is, that is how many characters can be 
  2076.    entered in the string.  Notice that we were careful not to make Field 
  2077.    larger than the string size so it would not overwrite too many characters 
  2078.    at MyString's address.  But what if the string can have up to 100 
  2079.    characters?  How can that be made to fit?
  2080.  
  2081.    Maximum Field - There are actually two variables to adjust the size of the 
  2082.    entry field, one is Field and the other is MaxField.  Rather than 
  2083.    explaining it, let's see what it can do.  First change the constant to:
  2084.  
  2085.      MyString: string[100] = 'This is my string.';
  2086.  
  2087.    and then add the variable setting of MaxField in the Data Window record:
  2088.  
  2089.      ...
  2090.      Field         := 25;
  2091.      MaxField      := pred(sizeof(MyString));      { = 100 }
  2092.      SaveDataWndw;
  2093.  
  2094.    Now when you run it, the field is flexible.  You can now enter up to 100 
  2095.    characters even though the field only displays 25.  These fields are called 
  2096.    flex fields.  
  2097.  
  2098.    Default Field - By default, program sets MaxField equal to Field.  Anytime 
  2099.    MaxField has been set and is not the equal to Field, the flex field becomes 
  2100.    active.  So, this can be used with any type of data and not just strings.
  2101.  
  2102.  
  2103.    TITLES
  2104.  
  2105.    If your field is wide enough, you can easily add a title.  Try adding the  
  2106.    following code to the MyStringDW record:
  2107.  
  2108.      GetDataWndw (ord(MyStringDW));
  2109.      Title         := 'Enter File Name';   
  2110.      VarAddr       := @MyString;
  2111.      ...
  2112.  
  2113.  
  2114.    Chapter 5, Data Windows                                             Page 35
  2115.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  2116.  
  2117.  
  2118.  
  2119.    Pulling down this data window, the title will be centered on the top row of 
  2120.    the window.  Titles are optional and will be truncated if necessary to fit 
  2121.    within the window.
  2122.  
  2123.  
  2124.    EDITING KEYS
  2125.  
  2126.    If you didn't get a chance to try out the full editing keys, here's the 
  2127.    list and their function:
  2128.  
  2129.      Keys                          Movement
  2130.      ----------------------------  -----------------------------------------
  2131.      Left Arrow / ^S               Character Left/Right
  2132.      Right Arrow / ^D              Character Left/Right
  2133.      Home / Ctrl Left  Arrow / ^A  First character
  2134.      End  / Ctrl Right Arrow / ^F  Last character
  2135.      Del / ^G                      Deletes character under cursor
  2136.      Backspace / ^H                Deletes character to left of cursor
  2137.      Ins / ^V                      Toggles between insert and overwrite mode
  2138.      ^R/^U                         Restores original contents
  2139.      ^Y                            Deletes entire contents
  2140.  
  2141.    Insert Toggle - PULL allows you to use both insert and overwrite mode.  You 
  2142.    can tell the status by the shape of the cursor.  The half-block cursor 
  2143.    indicates the insert mode which appears correctly in any video mode.
  2144.  
  2145.    Cursor Handling - In flex fields, some special cursor handling has also 
  2146.    been included that you will appreciate when the cursor is at either end.  
  2147.    When adding characters to the far right there is always one space open 
  2148.    until the maximum character is reached.  It helps identify the last 
  2149.    character and shows the character when the Del key is used.  The same 
  2150.    principle is used when backspacing - at least one character is always shown 
  2151.    until the last one is deleted.  The cursor always remains confined inside 
  2152.    the Field width on a flex field.
  2153.  
  2154.    One-Column Field - A special case is considered when Field is 1 column in 
  2155.    width.  The cursor does not move and any valid character typed in will 
  2156.    overwrite the contents.  Del or Backspace also deletes the contents.  
  2157.    Please do not consider using flex fields for this case.
  2158.  
  2159.    AutoNumLock - On machines with enhanced keyboards, it may be an advantage 
  2160.    to automatically turn on the NumLock when in Edit mode.  If so, by setting 
  2161.    AutoNumLock true, numeric key pad will be have the NumLock turned on when 
  2162.    you start editing.  After the edit, PULL will restore it to its original 
  2163.    mode, on or off.  Please note that even though the "NUM" message appears on 
  2164.    the message line to show the true internal status of NumLock, many machines 
  2165.    do not have a smart enough BIOS to also toggle the NumLock LED on the 
  2166.    keyboard itself.  Pressing the key can put it back in sync, but the "NUM" 
  2167.    message is the thing to watch.
  2168.  
  2169.  
  2170.    KEY SETS
  2171.  
  2172.    This section gives instructions on how to use TP's powerful sets to screen 
  2173.  
  2174.  
  2175.    Chapter 5, Data Windows                                             Page 36
  2176.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  2177.  
  2178.  
  2179.    for valid keystrokes into the data entry.
  2180.  
  2181.  
  2182.    Entry Sets - As a preventative measure, each keystroke is checked against a 
  2183.    set to see if it is valid before it is allowed into the field.  If it is 
  2184.    not, the keystroke is simply ignored.  Several set have included and a 
  2185.    default is given to each of the nine types of data:
  2186.  
  2187.      SetNames = (NoSet,UnsignedSet,SignedSet,RealSet,CharSet,
  2188.                  HexSet,FileNameSet,PathSet,MaskSet);
  2189.  
  2190.    where the following types are given the following sets:
  2191.  
  2192.      Type       Set
  2193.      ---------  -----------
  2194.      Bytes      UnsignedSet
  2195.      Words      UnsignedSet
  2196.      ShortInts  SignedSet
  2197.      Integer    SignedSet
  2198.      LongInts   SignedSet
  2199.      Reals      RealSet
  2200.      UserNums   CharSet
  2201.      Chars      CharSet
  2202.      Strings    CharSet
  2203.  
  2204.    Four more practical sets have also been included for your use.  To examine 
  2205.    the contents of the sets, they are located in P5X-VAR.INC in an array 
  2206.    called EntrySet.  Since it is in the include file for PULL, these can only 
  2207.    be modified when you have the complete source code.
  2208.  
  2209.    Assigning Sets - Most of your work can be done by default, but once in a 
  2210.    while, a custom set will be required.  Let's change MyString to be a file 
  2211.    name with only valid DOS characters by changing the MyStringDW record to:
  2212.  
  2213.      ...
  2214.      Field         := 25;
  2215.      MaxField      := pred(sizeof(MyString));      { = 100 }
  2216.      SetName       := FileNameSet;
  2217.      SaveDataWndw;
  2218.  
  2219.    Try entering a string into the window and find that invalid characters like 
  2220.    the space, "\", and "*" can not be entered.  This gives the user immediate 
  2221.    cues about the validity of the entry before it is completely entered.
  2222.  
  2223.  
  2224.    KEY TRANSLATION
  2225.  
  2226.    As each key is entered, it is possible to intercept the keystroke before it 
  2227.    reaches the data entry editor.  This section will show how it is done.
  2228.  
  2229.  
  2230.    Translation Pointer - Each data window record has a translation pointer 
  2231.    called TranslateProc.  You probably know by now, that the default is nil.  
  2232.    If a valid FAR procedure is assigned to this pointer, it will be executed.  
  2233.    Suppose you prefer to have the file name entries in upper case.  Modify 
  2234.  
  2235.  
  2236.    Chapter 5, Data Windows                                             Page 37
  2237.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  2238.  
  2239.  
  2240.    MyStringDW to:
  2241.  
  2242.      ...
  2243.      Field         := 25;
  2244.      MaxField      := pred(sizeof(MyString));      { = 100 }
  2245.      SetName       := FileNameSet;
  2246.      TranslateProc := @TranslateCase;
  2247.      SaveDataWndw;
  2248.  
  2249.    Back up a few lines to find this procedure and you will see:
  2250.  
  2251.      procedure TranslateCase;
  2252.      begin
  2253.        if not ExtKey then
  2254.          Key := upcase(Key);        { Simple upper case translation }
  2255.      end;
  2256.  
  2257.    In PULL, Key is the character returned from ReadKey, and ExtKey is true if 
  2258.    it is an extended key.  Notice that $F+ and $F- are used to force the 
  2259.    procedure to FAR.  Run the program again and find that all keys typed in 
  2260.    this data window are forced to upper case.
  2261.  
  2262.    Every Key - All keys can be translated with this procedure.  Even global 
  2263.    or editing keys can be intercepted and translated to whatever is desired.  
  2264.    It is also useful for foreign language translation.
  2265.  
  2266.  
  2267.    RANGE CHECKING
  2268.  
  2269.    After the entry is entered and checked as valid, there is one more option 
  2270.    of checking the entry to make sure it is in the range or form that is 
  2271.    acceptable to the program.  This section will show how to create range 
  2272.    checking procedures and out of range error messages.
  2273.  
  2274.  
  2275.    Three Parts - Before setting up a range check, you need to understand how 
  2276.    the data is transferred between the entry and the variable.  There are 
  2277.    three parts to performing the data entry transfer - the data entry string, 
  2278.    data pad, and destination variable.
  2279.  
  2280.    Data Entry String - The data entry string is the string that is seen and 
  2281.    edited on the CRT.  This string is held in DataStr of type DataStrType and 
  2282.    is declared in P5X-VAR.INC.
  2283.  
  2284.    Reading - The data pad, called DataPad, is a two-way messenger that 
  2285.    transfers data between the variable and DataStr.  When the data window is 
  2286.    initially displayed, the data pad reads the contents of the variable and 
  2287.    makes an exact copy of the value onto itself.  Then the program converts 
  2288.    this value over to DataStr into a string form which the user can easily 
  2289.    read and edit.
  2290.  
  2291.    Storing - As mentioned before, pressing RETURN after editing is completed, 
  2292.    the program attempts to store the entry to the variable.  First, numeric 
  2293.    data must pass a validity check by converting DataStr to a value.  If it 
  2294.    passes, a copy of the converted data is now on the data pad.  Now is the 
  2295.  
  2296.  
  2297.    Chapter 5, Data Windows                                             Page 38
  2298.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  2299.  
  2300.  
  2301.    time to do a data range check.  By default, there is no check and the data 
  2302.    would continue to be stored from the data pad to the destination variable 
  2303.    as is.  But to do the range check, you need to know the identifiers that 
  2304.    are used on the data pad.
  2305.  
  2306.    Data Pad Identifiers - The data pad is completely generic.  Any type of 
  2307.    data occupies the exact same address.  So all you need to do is select the 
  2308.    right identifier to match the type of data for your variable.  You can look 
  2309.    at the data pad record in P5X-VAR.INC for the field list, but here is a 
  2310.    list of those identifiers:
  2311.  
  2312.      Type       Identifier
  2313.      ---------  ----------
  2314.      Bytes      Bdata
  2315.      Words      Wdata
  2316.      ShortInts  SIdata
  2317.      Integers   Idata
  2318.      LongInts   Ldata
  2319.      Reals      Rdata
  2320.      UserNums   UNdata
  2321.      Chars      Cdata
  2322.      Strings    Sdata
  2323.  
  2324.    Example - Let's set up a range check for aByteDW.  Modify its data window 
  2325.    record to:
  2326.  
  2327.      GetDataWndw (ord(aByteDW));         { Just gets cleared DataWndw }
  2328.      ...
  2329.      Field         := 3;
  2330.      CheckRangeProc := @CheckAbyte;      { add this line. }
  2331.      SaveDataWndw;                       { Saves it in the heap }
  2332.  
  2333.    Arbitrarily, let the range for aByte be between 20 and 50 inclusive.  Now 
  2334.    back up a few lines before the TranslateCase procedure and the following 
  2335.    procedure has already been added for you:
  2336.  
  2337.      procedure CheckAbyte;
  2338.      begin
  2339.        with DataPad do
  2340.          if ((Bdata<20) or (Bdata>50)) then
  2341.            MakeErrMsg (20,50);
  2342.      end;
  2343.  
  2344.    Since aByte is byte type, Bdata is used for the comparison.  For the range 
  2345.    check, any values under 20 or over 50 will run the MakeErrMsg procedure.  
  2346.    Try it and see if you can produce the error message.
  2347.  
  2348.    Error Messages - How does PULL know if an error is found?  It tests the 
  2349.    value of ErrMsg in DataPad.  If the value remains zero, then the range 
  2350.    check is passed.  Otherwise, it has failed.  And, it uses this same value 
  2351.    as the error message name.  The ErrMsgLines are much like the MsgLines 
  2352.    using names for indexes.  Right after the implementation you can see the 
  2353.    error message names:
  2354.  
  2355.      ErrMsgNames = (NoEM,UserEM,InvalidEM,MyEM);
  2356.  
  2357.  
  2358.    Chapter 5, Data Windows                                             Page 39
  2359.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  2360.  
  2361.  
  2362.  
  2363.    The names up to InvalidEM are reserved.  The name UserEM is of most 
  2364.    interest.  ErrMsgLine[ord(UserEM)] is meant to be customized by creating a 
  2365.    message at run-time.  This saves you from making several hard-coded 
  2366.    messages.  The example used MakeErrMsg, located a few lines back.  It is a 
  2367.    good simple example how to set both ErrMsg and create a custom message on 
  2368.    the UserEM.  But the important value is the change of ErrMsg.
  2369.  
  2370.    Message Length - Error messages tend to be short, so there is no need to 
  2371.    allocate a full screen width for the message.  The maximum length of a 
  2372.    message is set by MaxErrStrLength in P5X-VAR.INC.  The program will 
  2373.    automatically clear the remaining part of the line and takes special care 
  2374.    not to do a needless full-line clear and thereby preventing a flicker 
  2375.    effect.
  2376.  
  2377.    Maximum Message - Similarly, the maximum number of ErrMsgLines is set by 
  2378.    NumOfErrMsgLines in P5X-VAR.INC.
  2379.  
  2380.    Summary - The outcome of the range check is determined by the value of 
  2381.    DataPad.ErrMsg.  PULL sets it to zero.  Compare your range with the DataPad 
  2382.    identifiers in any fashion.  Only if it is out of range, set ErrMsg to the 
  2383.    ErrMsgLine you want to show.
  2384.  
  2385.  
  2386.    HELP MESSAGES
  2387.  
  2388.    A help message can be assigned to the Data Window record exactly the same 
  2389.    as the menus.  One name has already been reserved for the Data Window 
  2390.    called DW_ML and is the default.  But you can also assign new ones.  The 
  2391.    MsgLines and names are in PULLSTAT.PAS.
  2392.  
  2393.  
  2394.    HELP WINDOWS
  2395.  
  2396.    Again, just like the menus, help windows can be assigned to the Data 
  2397.    Window.  The record name reserved for Data Window records is called 
  2398.    DataWndwHW and is the default.  If you have not seen this window, run the 
  2399.    program with a Data Window pulled and press F1.  The Help Window records 
  2400.    and Help Lines are in PULLSTAT.PAS.
  2401.  
  2402.  
  2403.    DEFAULT ATTRIBUTES AND BORDER
  2404.  
  2405.    This section will show the variables used to create default attributes and 
  2406.    border for the Data Window.
  2407.  
  2408.  
  2409.    Initialization - PULLDATA is self-initialized when it is included in the 
  2410.    USES list.  There are two procedures that set up the colors and border:
  2411.  
  2412.      SetDefaultColors - assigns colors and border to the default variables.
  2413.      InitDataColors   - assigns the defaults to the Data Window record.
  2414.  
  2415.    SetDefaultColors - In PULLDATA, search for SetDefaultColors and see the 
  2416.    following code:
  2417.  
  2418.  
  2419.    Chapter 5, Data Windows                                             Page 40
  2420.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  2421.  
  2422.  
  2423.  
  2424.      DataWndwIattr  := Black+BrownBG;
  2425.      DataWndwOattr  := Yellow+BlackBG;
  2426.      DataWndwBattr  := Black+BrownBG;
  2427.      DataWndwBrdr   := HdoubleBrdr;
  2428.  
  2429.    InitDataColors - These variables in turn are assigned to the following 
  2430.    record variables in DataWndw:
  2431.  
  2432.                        Record
  2433.      Default variable  Variable   Description
  2434.      ----------------  ---------  ----------------------------
  2435.      DataWndwIattr     Iattr      Attribute for Input
  2436.      DataWndwOattr     Oattr      Attribute for Output
  2437.      DataWndwBattr     Battr      Attribute of the Border
  2438.      DataWndwBrdr      Border     Border of the window
  2439.  
  2440.    Just like the menus, this saves you from having to make the same assignment 
  2441.    to every menu record.  Try experimenting with the colors and border in the 
  2442.    shell program and see the results.  Although NoBrdr is permissible, it is 
  2443.    not suggested.
  2444.  
  2445.  
  2446.    DEFAULT LOCATION
  2447.  
  2448.    The location of a data window is placed by PULL at run time.  With the 
  2449.    slide-under configuration, the menu is placed underneath the HiLite and 
  2450.    shifted to the right 2 columns.  If necessary, it is shifted to the left to 
  2451.    prevent wraparound.  To alter this position manually, set Row and Col in 
  2452.    the menu record to your desired location.
  2453.  
  2454.  
  2455.    SUMMARY
  2456.  
  2457.    In addition to mastering the menus, you can now link data windows into the 
  2458.    menus by adding and linking data window records in PULLDATA.PAS.  You have 
  2459.    been able to address the entry variable and create a window suitable for 
  2460.    the data type including the field type and size, title, key set and 
  2461.    translation, range checking, error and help messages, and help windows.  
  2462.    With this environment in your application along with the power and speed of 
  2463.    QWIK and WNDW, your programs can match and even better professional 
  2464.    programs.
  2465.  
  2466.  
  2467.  
  2468.  
  2469.  
  2470.  
  2471.  
  2472.  
  2473.  
  2474.  
  2475.  
  2476.  
  2477.  
  2478.  
  2479.  
  2480.    Chapter 5, Data Windows                                             Page 41
  2481.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  2482.  
  2483.  
  2484.    6.  D A T A   E N T R Y
  2485.  
  2486.    Data Windows in the pull-down menus are not the only place where data is 
  2487.    needed to be entered.  The work windows themselves may need several data 
  2488.    entry fields as well.  PULL simply uses a subset of Data Windows to handle 
  2489.    the job very easily.  In addition, a smart HiLite automatically knows the 
  2490.    location of each field in the window.
  2491.  
  2492.  
  2493.    DATA ENTRY vs. DATA WINDOW
  2494.  
  2495.    Data Windows have both a data entry field and a window surrounding it.  In 
  2496.    work windows, all that is needed is the data entry field.  So, to 
  2497.    distinguish between data entry in the pull-down menus and the work windows, 
  2498.    the Data Windows are only in the menus, while Data Entry will be considered 
  2499.    in this document to be in the work windows.
  2500.  
  2501.  
  2502.    DATA ENTRY RECORD
  2503.  
  2504.    One Data Entry field has already been included in the work window.  Let's 
  2505.    take a look at its record.  In PULLDATA, find GetDataEntryStats and search 
  2506.    for "with TopEntry" to see the following code:
  2507.  
  2508.      GetDataEntry (ord(aIntegerDE));
  2509.      VarAddr     := @aInteger;
  2510.      TypeOfData  := Integers;
  2511.      Row         := 2;
  2512.      Col         := 11;
  2513.      Field       := 4;
  2514.      MaxField    := 3;
  2515.      CheckRangeProc := @VerifyAinteger;
  2516.    { MsgLineNum  := ord(DE_ML); }      { This is the default }
  2517.    { HelpWndwNum := ord(DataWndwHW); } { This is the default }
  2518.      SaveDataEntry;
  2519.  
  2520.    The record identifiers should look quite familiar because they are the same 
  2521.    ones use in a Data Window record.  The only differences are the Get and 
  2522.    Save procedures, because the record is of type DataEntryRec rather than 
  2523.    DataWndwRec.  If you examine these type declarations in P5X-VAR.INC, you 
  2524.    will find there is a DataEntryRec inside of DataWndwRec.  So, Data Entry is 
  2525.    truly a subset of Data Windows.
  2526.  
  2527.    Variable - The variable is aInteger which is a constant declared early in 
  2528.    the file and is of type Integers.
  2529.  
  2530.    Row/Col - This time, a row and column is specified where the left column of 
  2531.    the field is to appear in the work window.  These coordinates are window 
  2532.    relative.
  2533.  
  2534.    Default Helps - Both the help message and help window are set to a default 
  2535.    so your program can be up and running without being concerned about 
  2536.    details.  Being in a different part of the pull-down menu environment, the 
  2537.    DE_ML is different from DW_ML because the function of F2 is the opposite to 
  2538.    either case.
  2539.  
  2540.  
  2541.    Chapter 6, Data Entry                                               Page 42
  2542.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  2543.  
  2544.  
  2545.  
  2546.    Other Variables - All the other variables in the record should be familiar 
  2547.    to you from the explanations in the previous section on Data Windows.  So, 
  2548.    there is no need to repeat them here.
  2549.  
  2550.  
  2551.    ADDING ENTRIES
  2552.  
  2553.    Entry Record - We have already seen how to add entries with the fill-in-
  2554.    the-blank concept, so let's try adding another entry to the work window.  
  2555.    Just after the aInteger record, add the following code:
  2556.  
  2557.      GetDataEntry (ord(aRealDE));
  2558.      VarAddr     := @aReal;
  2559.      TypeOfData  := Reals;
  2560.      Row         := 3;
  2561.      Col         := 11;
  2562.      Field       := 12;
  2563.      Decimals    := 2;
  2564.      SaveDataEntry;
  2565.  
  2566.    Decimal - This variable is just for reals to format the number of decimals 
  2567.    for the output display.  If the value is negative, then no decimal is used.
  2568.  
  2569.    aReal - Be sure to set up a default value for aReal.  At the beginning of 
  2570.    PULLDATA, add the constant aReal:
  2571.  
  2572.      ...
  2573.      aInteger: integer = 200;
  2574.      aReal:    real    = 4.56e7;
  2575.  
  2576.    aRealDE - Now append the data entry record name to the DataEntryNames list 
  2577.    at the beginning of the file:
  2578.  
  2579.      DataEntryNames = (NoDE,aIntegerDE,aRealDE);
  2580.  
  2581.    Now run the code and see if it appears in the Work Window.  When it runs, 
  2582.    the field does not appear.  Why?
  2583.  
  2584.  
  2585.    DISPLAYING FIELDS
  2586.  
  2587.    Work Window - The Work Window controls what is to appear inside the window 
  2588.    and this code is in the file PULLWORK.PAS.  Note that PULLWORK uses 
  2589.    PULLDATA.  Take a look at it and search for "case WorkWndwStep" and see:
  2590.  
  2591.      ...
  2592.      WWrite (2,2,'Integer:');
  2593.      DisplayFields (ord(aIntegerDE),ord(aIntegerDE));
  2594.      WorkWndwStep := 1;
  2595.      ...
  2596.  
  2597.    DisplayFields - This is the code that displayed the Integer field.  The 
  2598.    DisplayFields procedure displays a sequence of fields in order of the list 
  2599.    of DataEntryNames.  It is declared in the interface of PULL as:
  2600.  
  2601.  
  2602.    Chapter 6, Data Entry                                               Page 43
  2603.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  2604.  
  2605.  
  2606.  
  2607.      procedure DisplayFields (First,Last: word);
  2608.  
  2609.    So, what it does is display each field starting with the record First and 
  2610.    ending with Last.  Looking back in PULLWORK again, it displayed records 
  2611.    both beginning and ending with aIntegerDE.  So, it never reached aRealDE.  
  2612.    Let's modify the parameter to include aRealDE as follows:
  2613.  
  2614.      DisplayFields (ord(aIntegerDE),ord(aRealDE));
  2615.  
  2616.    Field Label - Running it, the aRealDE will be displayed this time.  But it 
  2617.    doesn't have a label, so add one to the window with:
  2618.  
  2619.      ...
  2620.      WWrite (2,2,'Integer:');
  2621.      WWrite (3,2,'Real:');
  2622.      DisplayFields (ord(aIntegerDE),ord(aRealDE));
  2623.      ...
  2624.  
  2625.    Justification - aReal now appears on the screen with the field right 
  2626.    justified.  By default, numbers are justified to the right and strings to 
  2627.    the left.  To alter this, just include your setting in the Data Entry 
  2628.    record.  Let's try left justifying aReal by adding the following code in 
  2629.    PULLDATA:
  2630.  
  2631.      GetDataEntry (ord(aRealDE));
  2632.      ...
  2633.      Decimals    := 2;
  2634.      JustifyOutput := Left;           { Add this line. }
  2635.      SaveDataEntry;
  2636.  
  2637.    Everything appears correctly on the screen.  But when we try to move the 
  2638.    HiLite, it just stays on the Integer field.  How can we make it select the 
  2639.    other field?  Real easy - keep reading.
  2640.  
  2641.  
  2642.    SEQUENTIAL ENTRY
  2643.  
  2644.    With sequential entries of several fields, PULL gives you the advantage of 
  2645.    using not just one movement with the HiLite, but both relative and 
  2646.    sequential movement.
  2647.  
  2648.  
  2649.    EnterSeq - PULL makes sequential entry as natural as can be.  In PULLWORK, 
  2650.    search for EnterSeq and see:
  2651.  
  2652.      EnterSeq (ord(aIntegerDE),ord(aIntegerDE),Start1);
  2653.  
  2654.    This procedure is also in the interface of PULL.PAS and is declared as:
  2655.  
  2656.      procedure EnterSeq (First,Last: word; VAR Start: word);
  2657.  
  2658.    EnterSeq allows you to enter a whole block of entries in the DataEntry 
  2659.    array of records where First and Last are the first and last records in the 
  2660.    block.  The aRealDE was not included in this block.  So let's modify the 
  2661.  
  2662.  
  2663.    Chapter 6, Data Entry                                               Page 44
  2664.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  2665.  
  2666.  
  2667.    code to:
  2668.  
  2669.      EnterSeq (ord(aIntegerDE),ord(aRealDE),Start1);
  2670.  
  2671.    Now run the code and find that the highlight can now move freely between 
  2672.    the two fields.  That all there is to do!  PULL handles the rest, now.  
  2673.  
  2674.    Start - Start is the record where the highlight is to begin.  At the bottom 
  2675.    of the file, Start1 is initialized to aIntegerDE.  Or, Start1 could be made 
  2676.    into a typed constant with a default value.  This lets EnterSeq remember 
  2677.    where the HiLite is after using the menus.
  2678.  
  2679.    Smart HiLite Algorithms - Take a break from PULLSHEL and go back to 
  2680.    PULLDEMO.  Run the program and take a look at the work window with several 
  2681.    entries.  PULL has smart algorithms that know where all the fields are 
  2682.    located on the screen.  The HiLite can be moved freely to select any field 
  2683.    with the following keys:
  2684.  
  2685.      Keys                     Movement                   Type of Movement
  2686.      -----------------------  -------------------------  ----------------
  2687.      Left/Right Arrow         Left/Right                 Relative
  2688.      Up/Down Arrow            Up/Down nearest cursor     Relative
  2689.      Home / Ctrl Left  Arrow  First one on the row       Relative
  2690.      End  / Ctrl Right Arrow  Last one on the row        Relative
  2691.      PgUp / Ctrl Home         First in sequence          Sequential
  2692.      PgDn / Ctrl End          Last  in sequence          Sequential
  2693.      Tab / Shift Tab          Next/Previous in sequence  Sequential
  2694.  
  2695.    Relative Movement - PULL checks the block of entries to see where to move 
  2696.    the HiLite relative to the current field.  If the field is already at its 
  2697.    limit, say to the far left with the left arrow key, it does not wrap around 
  2698.    to the far right.  When the HiLite is moved up or down, PULL looks for the 
  2699.    field nearest the cursor, not the full width of the field, and also does 
  2700.    not wrap.
  2701.  
  2702.    Sequential Movement - Primarily, the Tab key is used for sequential 
  2703.    movement.  If you reach the end of the sequence, the next Tab will wrap 
  2704.    back to the first.  What determines sequential movement?  It's the order of 
  2705.    the DataEntryNames.  So, changing the sequence is as simple as reorganizing 
  2706.    the names - no interlinks between fields are necessary!  Now you can insert 
  2707.    a new field without fretting over links.
  2708.  
  2709.    Auto Tab - The value of sequential entry is the order in which you want to 
  2710.    enter fields.  After entering one field, the program should be smart enough 
  2711.    to go the next one.  With AutoTab set true, PULL will jump to the next 
  2712.    field in sequence automatically after each entry.  Let's try it again on 
  2713.    the PULLDEMO program.
  2714.  
  2715.      1. Get into the work window.
  2716.      2. Press PgUp to get to the "Byte" entry field.
  2717.      3. Enter any value in range and press RETURN.
  2718.      4. See that the HiLite is now on "Integer".
  2719.  
  2720.    To prove the point of relative and sequential movement, let's move one of 
  2721.    the fields to a different location.  In PULLDATA, search for the data entry 
  2722.  
  2723.  
  2724.    Chapter 6, Data Entry                                               Page 45
  2725.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  2726.  
  2727.  
  2728.    record for aChar2DE, and change the location to:
  2729.  
  2730.      GetDataEntry (ord(aChar2DE));
  2731.      VarAddr     := @aChar2;
  2732.      TypeOfData  := Chars;
  2733.      Row         := 5;            { Change the row (was 15) }
  2734.      Col         := 5;            { Change the column (was 55) }
  2735.      ...
  2736.  
  2737.    Run PULLDEMO and see the field moved to (5,5).  Moving the up arrow as far 
  2738.    as it will go, the HiLite will end up on aChar2DE.  But when you press Tab, 
  2739.    the next field is String.  Now, suppose we want aChar2DE to be first in 
  2740.    sequence.  How easy is it?  Look for DataEntryNames at the top of the file 
  2741.    and see:
  2742.  
  2743.      DataEntryNames = (
  2744.        NoDE,aByte2DE,aWord2DE,aShortInt2DE,aInteger2DE,aLongInt2DE,aReal2DE,
  2745.        aHex2DE,aChar2DE,aString2DE,FileNameDE);
  2746.  
  2747.    There is a bunch of names here, but all we are interested in is moving 
  2748.    aChar2DE.  Move the name to be right after NoDE.  But now we have changed 
  2749.    the beginning name of the block from aByte2DE to aChar2DE.  So, go into 
  2750.    PULLWORK and do a global search and replace of aByte2DE with aChar2DE.  
  2751.    Three familiar lines will be changed.  Run the program now and see that 
  2752.    PgUp will now move the HiLite to the top and a subsequent tab will move it 
  2753.    to Byte.  This makes organizing your screen very easy.  
  2754.  
  2755.    Setting AutoTab - In PULLDATA, search for AutoTab which is right at the 
  2756.    beginning of the Data Entry records.  The current value is true.  If this 
  2757.    value is set false, then the HiLite would stay in the same field after 
  2758.    entry.
  2759.  
  2760.  
  2761.    EDIT MODE
  2762.  
  2763.    When the HiLite moves from field to field, it is in Select Mode.  But when 
  2764.    your are editing a field, it is in Edit Mode.  What exactly makes it change 
  2765.    from Select to Edit mode?  
  2766.  
  2767.  
  2768.    Overwrite vs. Edit - To overwrite the contents, just start typing the new 
  2769.    entry.  To edit the contents, the suggested key to use is the Return key.  
  2770.    When pressed, the HiLite changes color and the cursor is set past the last 
  2771.    character.
  2772.  
  2773.    Non-Extended Keys - In addition to the Return key, any non-extended key 
  2774.    will work as well and will also apply that key to the field.  For example, 
  2775.    while in select mode, if ^A is pressed, the HiLite would change into Edit 
  2776.    mode and, in addition, the cursor would be moved to the first character.
  2777.  
  2778.    Invalid Characters - If the key pressed is not a member of the entry key 
  2779.    set, it acts the same as return on the first key, but is otherwise ignored.
  2780.  
  2781.    Escape - To escape Edit mode and restore the original contents, just press 
  2782.    ESC and the HiLite will return to Select Mode.  If ESC is pressed again, 
  2783.  
  2784.  
  2785.    Chapter 6, Data Entry                                               Page 46
  2786.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  2787.  
  2788.  
  2789.    the program would escape the entire sequence of entry and would return 
  2790.    control to the WorkWindow procedure.
  2791.  
  2792.  
  2793.    FIELD ATTRIBUTES
  2794.  
  2795.    There are three attributes that can be modified for the Data Entry fields - 
  2796.    the display, the edit, and the HiLite attributes.
  2797.  
  2798.  
  2799.    Default Attributes - Data Entry fields have default attributes for each 
  2800.    record just like the Data Windows.  These variables are also set in 
  2801.    SetDefaultColors and InitDataColors.
  2802.  
  2803.    SetDefaultColors - In PULLDATA, search for SetDefaultColors and see the 
  2804.    following code:
  2805.  
  2806.      DataEntryIattr  := Yellow+MagentaBG;
  2807.      DataEntryOattr  := Black+LightGrayBG;
  2808.  
  2809.    InitDataColors - These variables in turn are assigned to the following 
  2810.    record variables in DataEntry:
  2811.  
  2812.                        Record
  2813.      Default variable  Variable   Description
  2814.      ----------------  ---------  --------------------
  2815.      DataEntryIattr    Iattr      Attribute for Input
  2816.      DataEntryOattr    Oattr      Attribute for Output
  2817.  
  2818.    HiLite Bar - The HiLite attribute is set by the color on the data pad 
  2819.    called DataPad.Hattr.  This variable is right next to AutoTab in PULLDATA.  
  2820.    Rather than having both the cursor and the HiLite, the HiLite can be turned 
  2821.    off by assigning Hattr the value of SameAttr.  Then each field will appear 
  2822.    in its own display attribute.
  2823.  
  2824.  
  2825.    SINGLE ENTRY
  2826.  
  2827.    If you prefer to customize your own procedures, you can use the procedure 
  2828.    Enter in lieu of EnterSeq.  The procedure is declared in PULL as:
  2829.  
  2830.      procedure Enter (RecNum: word);
  2831.  
  2832.    This accesses the same powerful editing features as EnterSeq, but only 
  2833.    works on the one field indicated in the parameter.  It does not display the 
  2834.    fields before or after editing which must be done with DisplayFields.
  2835.  
  2836.  
  2837.    SUMMARY
  2838.  
  2839.    You have just covered enough features to master data entry in the work 
  2840.    windows or user windows.  You can enter the records, display and locate the 
  2841.    fields, control the sequence of entry, and adjust the appearance with the 
  2842.    justification and attributes.  You also learned how to direct PULL's built 
  2843.    in HiLite bar for field selection.
  2844.  
  2845.  
  2846.    Chapter 6, Data Entry                                               Page 47
  2847.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  2848.  
  2849.  
  2850.    7.  W O R K   W I N D O W S
  2851.  
  2852.    The bulk of your application needs to be displayed somewhere, and the Work 
  2853.    Windows are used for this purpose.  In this section, you will discover how 
  2854.    to integrate your work window procedures in a pull-down menu environment so 
  2855.    the program can randomly access any procedure.  In addition, you can create 
  2856.    a sophisticated multi-level window environment.
  2857.  
  2858.  
  2859.    MAKING STEPS
  2860.  
  2861.    In this section, you will find how to break down procedures into individual 
  2862.    steps and still allow the flow of execution to cycle through the Key 
  2863.    dispatcher.
  2864.  
  2865.     
  2866.    Requirements - When procedures are broken down into steps, your procedures 
  2867.    can do most anything.  But each step must exit with two settings:
  2868.  
  2869.      1. Assignment made for the next WorkWndwStep.
  2870.      2. Assignment made for Key and ExtKey.
  2871.  
  2872.    Example - Let's do an example to understand the flow of execution.  Get the 
  2873.    original files for PULLDEMO.PAS - PULLWORK and PULLDATA.  Now take a look 
  2874.    at the last of PULLWORK and see:
  2875.  
  2876.      procedure WorkWndw;
  2877.      begin
  2878.        ...
  2879.        case WorkWndwStep of
  2880.          0:  ShowFields;
  2881.          1:  EditFields;
  2882.        end;
  2883.      end;
  2884.  
  2885.    With this construct, your work can be separated into different steps.  To 
  2886.    add a new step, just insert one.  To demonstrate how to create a new step, 
  2887.    let's separate the left and right columns of the data entry fields into two 
  2888.    separate steps.  So, let's add step 2:
  2889.  
  2890.        ...
  2891.          0:  ShowFields;
  2892.          1:  EditFields;
  2893.          2:  EditFields2;
  2894.        end;
  2895.  
  2896.    and change EditFields to:
  2897.  
  2898.      procedure EditFields;
  2899.      begin
  2900.        DisplayFields (ord(FileNameDE),ord(FileNameDE));
  2901.        EnterSeq (ord(aByte2DE),ord(aReal2DE),Start1);    { Change this line. }
  2902.        if Key=EscKey then                                { Add this line. }
  2903.          WorkWndwStep := 2;                              { Add this line. }
  2904.      end;
  2905.  
  2906.  
  2907.    Chapter 7, Work Windows                                             Page 48
  2908.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  2909.  
  2910.  
  2911.  
  2912.    This will isolate the sequence to the left column of fields.  And now add 
  2913.    EditFields2:
  2914.  
  2915.      procedure EditFields2;
  2916.      begin
  2917.        DisplayFields (ord(FileNameDE),ord(FileNameDE));
  2918.        EnterSeq (ord(aHex2DE),ord(FileNameDE),Start2);
  2919.        if Key=EscKey then
  2920.          WorkWndwStep := 1;
  2921.      end;
  2922.  
  2923.    Start2 has already been added for you.  Set the TP primary file to be 
  2924.    PULLDEMO.PAS.  Now try the program and see that you can only access the 
  2925.    left or right sequence of fields.  If you want to swap between the left and 
  2926.    right columns, just press ESC.
  2927.  
  2928.    Flow of Execution - ESC has been assigned inside EnterSeq as the key that 
  2929.    is used to exit the procedure.  This is called a gated exit.  Once it 
  2930.    exits, it also exits WorkWndw and goes back into PULL to analyze the 
  2931.    keystroke in a key dispatcher.  If no key combinations are used to access 
  2932.    the menus, execution will return right back to WorkWndw and into the right 
  2933.    step.  You can catch the execution flow, by testing for the Esc key right 
  2934.    after EnterSeq.  If so, then change the step as we did in the example.
  2935.  
  2936.    Menu Access - Why even bother to test the key if ESC exits EnterSeq?  The 
  2937.    Esc key is not the only key that would exit this procedure.  Any menu key 
  2938.    like F10 will also exit the same way.  So, the "if" statement is needed to 
  2939.    confirm the correct key before changing the step.
  2940.  
  2941.    Updating the Window - Did you notice that DisplayFields was used twice for 
  2942.    just one field?  Any time you exit a menu and re-enter the window, there is 
  2943.    a possibility that something may need to be updated.  And this time the 
  2944.    File name field is a possibility because it was linked to the output of the 
  2945.    file directory.  If you haven't had a chance, press Alt-D to get the 
  2946.    directory and pick a file by pressing RETURN.  The selected file name will 
  2947.    appear in the File name field.  The other link is that the file name data 
  2948.    entry field also preselects the initial file name when the directory is 
  2949.    pulled again.  But there are other alternatives than using DisplayFields 
  2950.    twice.
  2951.  
  2952.    Changing Steps - This example was quite simple.  When step 1 was complete, 
  2953.    WorkWndwStep was incremented to step 2.  When step 2 was done, it was 
  2954.    cycled back to step 1.  It continues to stay in this loop until the program 
  2955.    is terminated, or until some other procedure changes the step number.  In 
  2956.    step 0, if we had failed to assign a new step at the end of the step, the 
  2957.    program would have been locked in an infinite loop, because it never 
  2958.    accesses any keyboard input.
  2959.  
  2960.  
  2961.    READING THE KEYBOARD
  2962.  
  2963.    In some steps, the program may need keyboard input while others do not.  In 
  2964.    this section you will find out how to read the keyboard within each step.
  2965.  
  2966.  
  2967.  
  2968.    Chapter 7, Work Windows                                             Page 49
  2969.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  2970.  
  2971.  
  2972.    Output-Only Step - Step 0 in the example, is an output-only step that 
  2973.    displays the fields in the window.  No keyboard input was required.  So, at 
  2974.    the end of the step, we needed to emulate a keystroke of some kind to meet 
  2975.    the Step requirements.  By setting Key to NullKey (#00), the key dispatcher 
  2976.    and will bypass a call to the menus and ignore the key.  This guarantees 
  2977.    that the flow of execution will return to back WorkWndw.  ExtKey should 
  2978.    also be set properly if a valid combination is needed.  Some keys do not 
  2979.    require it such as NullKey, EscKey, and RetKey.  See your reference book 
  2980.    for more details.
  2981.  
  2982.    Input and Output Step - Most steps will require both input and output.  
  2983.    Step 1 called EnterSeq which has a keyboard reading routine built in.  So, 
  2984.    no keystroke emulation is needed.  However, the last line in the step still 
  2985.    needs to check for a change of step.
  2986.  
  2987.    Custom Input - There will be several occasions where you will want to have 
  2988.    your own procedures that read the key board.  If you have the source code,  
  2989.    look at PULLDENT.INC for the construct of EnterSeq which looks like:
  2990.  
  2991.      repeat
  2992.        ...
  2993.        CheckForPullDown (ord(SeqML));
  2994.        ...
  2995.        CheckForPop;
  2996.      until (Key=EscKey) or Pop or PullDown;
  2997.  
  2998.    CheckForPullDown is a procedure available to you to read the key board.  
  2999.    Its parameter, MsgLineNum, will show this message while the program pauses 
  3000.    for entry.  A subroutine in CheckForPullDown is ReadKbd which can be used 
  3001.    instead.  It just reads the keyboard and does not show a message.
  3002.  
  3003.    CheckForPop - This procedure is also available to you to check if any menu 
  3004.    control flags have been set and regulates them.  If the flags indicate a 
  3005.    pop it needed, then Pop will be set true.
  3006.    
  3007.    Gated Exit - Now you can see two more possible reasons that would cause the 
  3008.    program to exit EnterSeq - Pop and PullDown.  These are the very same flags 
  3009.    used for controlling the menus.  By gating the exit, the flow of execution 
  3010.    is confined with the repeat/until construct until a control flag permits 
  3011.    the exit.  Using these two flags allow EnterSeq to be used in either the 
  3012.    Work Window or a User Window in the menus.  If the procedure is only going 
  3013.    to be used in the Work Window, then Pop is not necessary.
  3014.  
  3015.    Non-Gated Exit - The step doesn't have to be gated at all.  You can use 
  3016.    CheckForPullDown by itself if the flow of execution can continue through 
  3017.    the dispatcher every time a key is pressed.  For EnterSeq, this would not 
  3018.    work, because the HiLite would flash with each keystroke.  The next section 
  3019.    shows an example where a non-gated Exit works perfectly fine.
  3020.  
  3021.    Idle Keyboard - Rather than just letting the program just sit there and 
  3022.    wait for keyboard input, you could be letting the program do other 
  3023.    background processing.  An indirect call from PULL inside ReadKbd 
  3024.    continually runs the contents of the FAR procedure KbdIdle while no key is 
  3025.    pressed.  Although KbdIdle is seen here in PULLWORK, it can be placed in 
  3026.    any file, but it MUST be included somewhere, even if the procedure is 
  3027.  
  3028.  
  3029.    Chapter 7, Work Windows                                             Page 50
  3030.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  3031.  
  3032.  
  3033.    empty.  The variable AddKbdIdle declares its address.
  3034.  
  3035.  
  3036.    MULTI-LEVEL WINDOWS
  3037.  
  3038.    One work window may not be enough for your application and others may be 
  3039.    needed.  The following example shows how to add a simple hidden Work 
  3040.    Window.
  3041.  
  3042.    Making the Step - Add step 3 to WorkWindow:
  3043.  
  3044.        ...
  3045.          2:  EditFields2;
  3046.          3:  EditWorkWndw2;   { Add this line. }
  3047.        end;
  3048.  
  3049.    Now, create this editing step to just put ASCII keys into the window.  A 
  3050.    non-gated procedure will work fine:
  3051.  
  3052.      procedure EditWorkWndw2;
  3053.      begin
  3054.        CheckForPullDown (ord(WorkML));      
  3055.        if not ExtKey then
  3056.          case Key of
  3057.            #32..#126: write (Key);
  3058.            RetKey:    writeln;
  3059.            EscKey:    HideWorkWndw;
  3060.          end;
  3061.      end;     { Non-gated exit }
  3062.  
  3063.  
  3064.    The key chosen to hide the window is ESC although any key could be assigned 
  3065.    to do this.  But we also need to initialize the second work window to be 
  3066.    available to the program.  So, add the following line to InitWorkWndws:
  3067.  
  3068.      procedure InitWorkWndws;
  3069.      begin
  3070.        ShowFields;
  3071.        MakeWorkWndw2;   { Add this line. }
  3072.        ...
  3073.      end;
  3074.  
  3075.    and then code the procedure to make a hidden window and place it just after 
  3076.    the ShowFields procedure.  (The code is already there.  Just remove the 
  3077.    braces for this example.)
  3078.  
  3079.      procedure MakeWorkWndw2;
  3080.      begin
  3081.        SetWindowModes (HiddenMode);
  3082.        MakeWindow ( 8,21,10,40,LightBlue+LightGrayBG,LightBlue+LightGrayBG,
  3083.                     DoubleBrdr,Window2);
  3084.        SetWindowModes (0);
  3085.        WriteToHidden (Window2);
  3086.        TitleWindow (Top,Left  ,SameAttr,'2');
  3087.        TitleWindow (Top,Center,SameAttr,' Press ESC to hide ');
  3088.  
  3089.  
  3090.    Chapter 7, Work Windows                                             Page 51
  3091.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  3092.  
  3093.  
  3094.        TitleWindow (Top,Center,SameAttr,' Work Window 2 ');
  3095.        WWriteC (1,'Type in any input');
  3096.        WGotoRC (2,1);
  3097.        WriteToCRT;
  3098.      end;
  3099.  
  3100.    At the beginning of the file, let's also activate the multi-level work 
  3101.    window code by placing the "$" code in front of the word "define" to look 
  3102.    like:
  3103.  
  3104.      {$define MultiWorkWndws }
  3105.  
  3106.    This activates the AccessWorkWndw procedure which simply accesses the 
  3107.    selected window set by TopWorkWndwName.  When TopWorkWndwName has changed,  
  3108.    WorkWndwStep also needs to be reset.  In the procedure ResetWorkWndwStep, 
  3109.    confirm that Window2 starts on the correct step:
  3110.  
  3111.      Window2:  WorkWndwStep := 3;
  3112.  
  3113.    Now we need some keys to get access to these windows.  Let Window1 and 
  3114.    Window2 be assigned to the Alt-1 and Alt-2 keys.  To do this, go back to 
  3115.    PULLSTAT.PAS and edit CheckGlobalKeys to the following:
  3116.  
  3117.        ...
  3118.        AltX:    SetQuit;
  3119.        Alt1:    SetWorkWndw (Window1);
  3120.        Alt2:    SetWorkWndw (Window2);
  3121.      else
  3122.      ...
  3123.  
  3124.    The constants for Alt1 and Alt2 have already been set for you.  SetWorkWndw 
  3125.    is located just before CheckGlobalKeys and looks like:
  3126.  
  3127.      procedure SetWorkWndw (WN: WindowNames);
  3128.      begin
  3129.        PullDown        := false;
  3130.        PopToWorkWndw   := true;
  3131.        TopWorkWndwName := WN;
  3132.      end;
  3133.  
  3134.    This assigns a new Work Window name for the AccessWorkWndw procedure.  Now 
  3135.    it is all set.  Give the program a run.  You will see that anytime you 
  3136.    press Alt-1 or Alt-2, it immediately accesses that window even if you are 
  3137.    in the menus!  And, when you get Window2, the contents are preserved.  If 
  3138.    you were able to program this successfully, you have attained a highly 
  3139.    sophisticated environment with little code.
  3140.  
  3141.  
  3142.    MANAGING WINDOWS
  3143.  
  3144.    We have just covered all the code necessary to have several work windows on 
  3145.    the screen at once.  To randomly access any window, the Alt keys were 
  3146.    assigned to a particular window number.  To hide a window, the Esc key was 
  3147.    used and the contents were saved.
  3148.  
  3149.  
  3150.  
  3151.    Chapter 7, Work Windows                                             Page 52
  3152.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  3153.  
  3154.  
  3155.    Should you decide to use temporary windows so that ESC would remove the 
  3156.    window, just replace the two occurrences of HideWindow with RemoveWindow.  
  3157.    Of course, you could make a combination of both.  You now have the tools 
  3158.    for complete window management.
  3159.  
  3160.  
  3161.  
  3162.  
  3163.  
  3164.  
  3165.  
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.  
  3173.  
  3174.  
  3175.  
  3176.  
  3177.  
  3178.  
  3179.  
  3180.  
  3181.  
  3182.  
  3183.  
  3184.  
  3185.  
  3186.  
  3187.  
  3188.  
  3189.  
  3190.  
  3191.  
  3192.  
  3193.  
  3194.  
  3195.  
  3196.  
  3197.  
  3198.  
  3199.  
  3200.  
  3201.  
  3202.  
  3203.  
  3204.  
  3205.  
  3206.  
  3207.  
  3208.  
  3209.  
  3210.  
  3211.  
  3212.    Chapter 7, Work Windows                                             Page 53
  3213.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  3214.  
  3215.  
  3216.    8.  U S E R   W I N D O W S
  3217.  
  3218.    While in the menus, you may have to create a window or a menu that differs 
  3219.    from the ones in PULL.  This section will show you the pull-down directory 
  3220.    included with the package and how to integrate any user window into the 
  3221.    pull-down environment.
  3222.  
  3223.  
  3224.    PULL-DOWN DIRECTORY
  3225.  
  3226.    The pull-down directory unit has already been linked into the demo.  By 
  3227.    now, you can probably figure out how the directory is accessed.  Looking in 
  3228.    the FilesMenu, find the following code:
  3229.  
  3230.      Line[3]:='Directory';          LineMode[3]:=ToUserWndw;
  3231.                                     ProcPtr [3]:=@DoDir;
  3232.  
  3233.    To pull down a user window, the line mode is set to ToUserWndw which places 
  3234.    a 3-bar symbol on that line.  Then, DoDir is the procedure that will access 
  3235.    the directory and looks like:
  3236.  
  3237.      procedure DoDir;
  3238.      begin
  3239.        { Use (FileName,FileName) to initially Hilite a close match. }
  3240.        { Use (FileName,'') to start at default. }
  3241.        PullDirectory (FileName,FileName);
  3242.      end;
  3243.  
  3244.    PullDirectory handles every thing once inside the procedure.  A particular 
  3245.    emphasis was made on end-user human factors in its development.
  3246.  
  3247.      . Single column - A single column, alphabetically sorted list is the 
  3248.        easiest to visually scan quickly.  Multi-column lists such as the one 
  3249.        provided in the TP5 environment require difficult zig-zag scanning.
  3250.  
  3251.      . Cursor key scanning - Cursor keys are the expected way to scan through 
  3252.        the directory.  In addition, Home, ^Home, End, and ^End keys only move 
  3253.        the HiLite while PgUp, ^PgUp, PgDn, and ^PgDn move only the page.
  3254.  
  3255.      . Letter key scanning - Any alpha-numeric key will scan for the first 
  3256.        file name starting with the same first letter.  The page is moved and 
  3257.        the cursor is centered as much as possible.
  3258.  
  3259.      . Lower-case text - Lower case text is more legible than the standard 
  3260.        upper-case text provided by DOS.
  3261.  
  3262.      . Right justified extension - Visual searches for extensions are easier 
  3263.        to read when aligned.  In addition, this also facilitates proper 
  3264.        alphabetic sorting.
  3265.  
  3266.      . High speed sort - The sorting routine uses is a secondary-index quick 
  3267.        sort which is the fastest kind for this application.  It is currently 
  3268.        set at a limit of 250 file names are permitted, but it can be set to 
  3269.        grow as much as your heap allows.
  3270.  
  3271.  
  3272.  
  3273.    Chapter 8, User Windows                                             Page 54
  3274.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  3275.  
  3276.  
  3277.      . High speed scroll - The display is expected to be fast when scrolling 
  3278.        and is.  Neither the HiLite nor the screen ever flicker.
  3279.  
  3280.      . Default HiLite - If a value file name is passed to the directory for 
  3281.        the default other than '', the directory searches for a close match to 
  3282.        HiLite.  In either case, the HiLite is centered as much as possible.
  3283.  
  3284.      . Picked file name - Pressing CR will replace the referenced file name 
  3285.        passed to the directory.
  3286.  
  3287.  
  3288.    INTERFACE
  3289.  
  3290.    If you have the source code to PULLDIR.PAS, take a look at PullDirectory 
  3291.    and see how the code interfaces the pull-down menus.  This is an excellent 
  3292.    example of incorporating all the features to integrate with the menus:
  3293.  
  3294.      procedure PullDirectory; { (VAR NameToChange: FileNameStr;
  3295.                                      NameToHiLite: FileNameStr); }
  3296.      begin
  3297.        TurnArrows (On);                                         { 1 }
  3298.        with TopMenu do
  3299.          CmdSeq := CmdSeq+CmdLtrs[HiLiteLine];                  { 2 }
  3300.        ShowDirMenu (NameToHiLite);                              { 3 }
  3301.        repeat
  3302.          with DirectoryMenu do
  3303.            begin
  3304.              CheckForPullDown (DirectoryMenu.MsgLineNum);       { 4 }
  3305.              if ExtKey then
  3306.                begin
  3307.                  if HelpKeyPressed then
  3308.                    {$ifdef UseHelpWndwCode }
  3309.                    PullHelpWndw (HelpWndwNum)                   { 5 }
  3310.                    {$endif UseHelpWndwCode }
  3311.                  else ScanDirByCursor;
  3312.                end
  3313.              else
  3314.                if Key<>RetKey then
  3315.                  ScanDirByLetter;
  3316.              if (Key=RetKey) and (TotalFiles>0) then
  3317.                begin
  3318.                  PopToWorkWndw := true;                         { 6 }
  3319.                  { ... }
  3320.                end;
  3321.              CheckForPop                                        { 7 }
  3322.            end;  { with }
  3323.        until (Key=EscKey) or (Key=RetKey) or Pop;               { 8 }
  3324.        Key := NullKey;                                          { 9 }
  3325.        RemoveWindow;                                            { 10 }
  3326.        dec (CmdSeq[0]);                                         { 11 }
  3327.        TurnArrows (Off);                                        { 12 }
  3328.      end;
  3329.  
  3330.    Comments - Comments for the numbered lines follow.
  3331.  
  3332.  
  3333.  
  3334.    Chapter 8, User Windows                                             Page 55
  3335.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  3336.  
  3337.  
  3338.      Line 1  - TurnArrows is a procedure that places arrow symbols on 
  3339.                the top menu to direct the user's attention to the new 
  3340.                menu.
  3341.      Line 2  - Append CmdSeq so that PULL can know how it got to this 
  3342.                menu.
  3343.      Line 3  - This procedure actually produces the window on the CRT 
  3344.                and it custom designed.
  3345.      Line 4  - CheckForPullDown monitors keyboard entry and displays a 
  3346.                message.
  3347.      Line 5  - You can include your custom help window here.
  3348.      Line 6  - Once the item was selected on the menu, this option 
  3349.                commands PULL to return to the top work window.  This is 
  3350.                optional.
  3351.      Line 7  - CheckForPop analyzes all the menu controls flags, 
  3352.                including PopToWorkWndw, to see if a request has been 
  3353.                made to pop out of the menu.  If so, Pop is set to true.
  3354.      Line 8  - The repeat/until construct provides a gated exit.
  3355.      Line 9  - Alter the value of Key so the next menu will ignore an 
  3356.                EscKey value.  ESC is meant to pop only one menu.  If the 
  3357.                key was not changed, the menus would continue to pop 
  3358.                until is was back into the work window.
  3359.      Line 10 - The exit has been confirmed and the window/menu needs to 
  3360.                be removed from the CRT.
  3361.      Line 11 - Adjust CmdSeq for one pop.
  3362.      Line 12 - Turn the arrows back off of the top menu.
  3363.  
  3364.    This same construct can be used for any user window/menu to be included 
  3365.    with the pull-down menus.
  3366.  
  3367.  
  3368.  
  3369.  
  3370.  
  3371.  
  3372.  
  3373.  
  3374.  
  3375.  
  3376.  
  3377.  
  3378.  
  3379.  
  3380.  
  3381.  
  3382.  
  3383.  
  3384.  
  3385.  
  3386.  
  3387.  
  3388.  
  3389.  
  3390.  
  3391.  
  3392.  
  3393.  
  3394.  
  3395.    Chapter 8, User Windows                                             Page 56
  3396.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  3397.  
  3398.  
  3399.    9.  C O N D I T I O N A L   C O M P I L A T I O N
  3400.  
  3401.    Many times your application may not need to use all of the features built 
  3402.    into PULL.  Although most of the code is optimized out by the compiler, 
  3403.    some of the code is nested and it would be helpful to eliminate some of 
  3404.    that code.  This section will show you how easy it is to do this.
  3405.  
  3406.  
  3407.    DEFINE SYMBOLS
  3408.  
  3409.    Here is a complete list of the define symbols used in PULL:
  3410.  
  3411.      UseSubMenuCode   - to include submenus.
  3412.      UseHelpWndwCode  - to include help windows.
  3413.      UseDataEntryCode - to include data entry or data windows.
  3414.      UseMsgLineCode   - to include normal and error messages.
  3415.      MultiWorkWndws   - to include multi-level work windows.
  3416.  
  3417.    Location - You can find these directives defined on the first page of all 
  3418.    *.PAS files.  Most files will not have every one of them, but only the ones 
  3419.    that affect it.
  3420.  
  3421.    Definition - When you see the define directive, it will look like:
  3422.  
  3423.      {$define UseSubMenuCode }
  3424.  
  3425.    With the "$" in its place, UseSubMenuCode would be defined and would 
  3426.    include all of the submenu code.  If you do not want the code, then 
  3427.    undefine it by just removing the "$":
  3428.  
  3429.      { define UseSubMenuCode }
  3430.  
  3431.    Affected Files - Should you decide to undefine a symbol, you should 
  3432.    undefine it in ALL affected files including PULL.  You can get away without 
  3433.    changing PULL on all of them except UseMsgLineCode where you must change it 
  3434.    in PULL as well.
  3435.  
  3436.  
  3437.    RECOMPILING
  3438.  
  3439.    Once you have changed all the needed directives, do a Make and the code 
  3440.    will be ready for use.
  3441.  
  3442.  
  3443.  
  3444.  
  3445.  
  3446.  
  3447.  
  3448.  
  3449.  
  3450.  
  3451.  
  3452.  
  3453.  
  3454.  
  3455.  
  3456.    Chapter 9, Conditional Compilation                                  Page 57
  3457.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  3458.  
  3459.  
  3460.    10.  T R O U B L E   S H O O T I N G
  3461.  
  3462.    PULL is a well thought out unit.  If you find that the program has not done 
  3463.    what you expected, there may be something that you overlooked.  This 
  3464.    section will try to help jog your memory as to what the problems may be.
  3465.  
  3466.  
  3467.    GOOF UNIT
  3468.      
  3469.    All programmers make mistakes, right?  So, what happens when you try to 
  3470.    make more windows than there are records available?  Since WNDW and PULL 
  3471.    are powerful tools and can even write in RAM, there is a good possibility 
  3472.    that your mistake may not even show up on the screen.  How do you know if 
  3473.    anything has gone wrong?  The GOOF unit was made especially for handling 
  3474.    errors.
  3475.  
  3476.    Displaying Errors - When an error is found in your program, the ShowGoof 
  3477.    procedure is called and the program is terminated.  The CRT will display an 
  3478.    error message in a flashing window.  There are eight fatal errors that are 
  3479.    listed in APPENDIX B in WNDWREF.DOC to identify problems before they 
  3480.    happen.  Please refer to it for the error messages and their solutions.  If 
  3481.    you do not have a copy of WNDW5XA.ARC, you can get one direct from the 
  3482.    Eagle.
  3483.  
  3484.    Flexibility - ShowGoof is accessed indirectly with an indirect call.  This 
  3485.    means that you can freely edit the GOOF unit without needing to recompile 
  3486.    WNDW or PULL.  You can even edit it for use in your own applications.  The 
  3487.    error message numbers 1-50 are reserved.  So, for your own applications, it 
  3488.    is suggested that you start with number 51.  If you have thoroughly tested 
  3489.    your program, some of the messages can be eliminated.  
  3490.  
  3491.    Using GOOF - It is very important that GOOF be included in the USES list.  
  3492.    You may find that it compiles without it, but if an error does occur, your 
  3493.    system will surely crash.  Notice that GOOF is the last unit in the USES 
  3494.    list in the main program.
  3495.  
  3496.  
  3497.    FAR ADDRESSES
  3498.  
  3499.    Because PULL uses several pointers for procedures and variables, it is 
  3500.    quite possible to lock up your computer if these are not properly 
  3501.    addressed.  A debugger is most helpful in these circumstances.  But if you 
  3502.    do not have one, here is a check list of possible causes:
  3503.  
  3504.  
  3505.    Forcing FAR - The far pointers used by TranslateProc, CheckRangeProc, and 
  3506.    ProcPtr must be calling FAR procedures.  All procedures that are not 
  3507.    declared in the interface of a unit must be forced to FAR with the 
  3508.    directive {$F+} when called by a pointer.
  3509.  
  3510.    Indirect Calls - PULL has several inline calls for indirect FAR calls 
  3511.    outside of the calling unit.  The addresses for these units must be 
  3512.    assigned in the destination unit with an Addr* variable and is usually done 
  3513.    in the BEGIN/END for initialization.  Here is a list of those procedures 
  3514.    and calling address variables:
  3515.  
  3516.  
  3517.    Chapter 10, Trouble Shooting                                        Page 58
  3518.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  3519.  
  3520.  
  3521.  
  3522.       Procedure         Address Variable      Unit    
  3523.       ----------------  --------------------  --------
  3524.       GetUserPullStats  AddrGetUserPullStats  PullStat
  3525.       GetOverrideStats  AddrGetOverrideStats  PullStat
  3526.       WorkWndw          AddrWorkWndw          PullWork
  3527.       CheckGlobalKeys   AddrCheckGlobalKeys   PullStat
  3528.       ShowGoof          AddrGoof              Goof
  3529.       KbdIdle           AddrKbdIdle           Any
  3530.  
  3531.    Using Units - Because of indirect calls, the compiler does not know that 
  3532.    some units need to be linked.  PullStat, PullWork, and Goof are three units 
  3533.    that MUST be in the USES list of the main program.
  3534.  
  3535.    KbdIdle - The far procedure KbdIdle must be used and can be located in any 
  3536.    unit.  This procedure does background processing while the keyboard is 
  3537.    idle.
  3538.  
  3539.    Data - The variable address and type of data in each data record must 
  3540.    exactly match or risk possible data loss.  Strings lengths must not be 
  3541.    longer than MaxField.
  3542.  
  3543.  
  3544.    MULTI-TASKING
  3545.  
  3546.    This demo can easily be set to work in multi-tasking environments by using 
  3547.    a file called DESQ5X.ARC.  It is a simple matter of setting the video 
  3548.    buffer pointer.  This demo does not include this file, but it is what is 
  3549.    needed to make it work.
  3550.  
  3551.  
  3552.    CUSTOMER SERVICE
  3553.  
  3554.    If you are still having problems, leave us a message or give us a call.
  3555.  
  3556.  
  3557.  
  3558.  
  3559.  
  3560.  
  3561.  
  3562.  
  3563.  
  3564.  
  3565.  
  3566.  
  3567.  
  3568.  
  3569.  
  3570.  
  3571.  
  3572.  
  3573.  
  3574.  
  3575.  
  3576.  
  3577.  
  3578.    Chapter 10, Trouble Shooting                                        Page 59
  3579.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  3580.  
  3581.  
  3582.    A P P E N D I X   A :   O T H E R   P R O D U C T S
  3583.  
  3584.  
  3585.    Eagle Performance Software has developed identical products for both Turbo 
  3586.    C and Turbo Pascal.  Our pledge is to provide you quality products with 
  3587.    unparalleled performance and ease of use.
  3588.  
  3589.  
  3590.    QWIK
  3591.  
  3592.    QWIK - For direct screen video, QWIK is the highest performance screen 
  3593.    writing tools available today for all text modes in any video 
  3594.    configuration.  QWIK provides capabilities far beyond in the unit/library 
  3595.    that comes with your compiler.   Here are some of the features:
  3596.                    
  3597.      . Writes on all IBM compatible computers, displays and adapters 
  3598.        including MDA, CGA, EGA, MCGA, VGA, 8514/A, Hercules and 3270 
  3599.        PC.
  3600.      . Superior video detection routine.
  3601.      . Eliminates snow and flicker.
  3602.      . Writes directly to the screen in absolute rather than relative 
  3603.        coordinates.
  3604.      . Writes in all text modes and column modes.
  3605.      . Writes on all video pages.
  3606.      . Writes on virtual screens in RAM.
  3607.      . Writes text and attribute, text only, or attribute only.
  3608.      . Reads strings, characters and attributes.
  3609.      . Uses End-Of-String (EOS) marker for quick string chaining.
  3610.      . Provides standardized cursor shapes for all adapters.
  3611.      . Enhanced cursor movement.
  3612.      . Compatible with DESQview and similar multitasking environments.
  3613.      . Over 650% faster than standard direct screen writing.
  3614.      . Only 2.7k bytes of code if all 43 utilities are used.
  3615.      . Optimized by the compiler and drops unused code.
  3616.      . Used in all other Eagle products.
  3617.  
  3618.    Here are the product versions:
  3619.  
  3620.       File name    CIS name    Compiler  Release date
  3621.       -----------  ----------  --------  ------------
  3622.       QWIK42B.ARC  QWIK42.ARC  TP4(TP5)   10-01-88
  3623.       QWIK5X.ARC   QWIK5X.ARC  TP5(TP4)   12-20-88
  3624.       QWIK50.ARC   QWIK50.ARC  TP5        TBA
  3625.       QWIKC20.ARC  QWKC20.ARC  TC2        12-03-88
  3626.  
  3627.  
  3628.    WNDW
  3629.  
  3630.    WNDW - For multi-level virtual windows, WNDW is the highest performance 
  3631.    window utilities available today.  It offers very powerful utilities for 
  3632.    full window control and management you probably never thought possible.   
  3633.    They are simple and yet very powerful with high speed and tight code.  With 
  3634.    WNDW, you can choose the absolute writing routines of QWIK, the window-
  3635.    relative writing routines of WNDW, and even customize your own.  Here are 
  3636.    some of the features you will discover:
  3637.  
  3638.  
  3639.    Appendix A: Other Products                                          Page 60
  3640.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  3641.  
  3642.  
  3643.  
  3644.    . Uses the powerful direct screen writing routines of QWIK.
  3645.    . Up to 254 fixed or virtual windows can be on the screen at one time.
  3646.    . Extremely high-speed virtual screens in RAM (up to 40 times faster).
  3647.    . Virtual windows are fully updated on screen, even if covered!
  3648.    . Virtual windows have virtual titles.
  3649.    . Fully supported hidden windows saved in RAM.
  3650.    . Fully supports all video pages.
  3651.    . Adjustable-rate moving, resizing, and scrolling.
  3652.    . All windows can be randomly accessed, not just stacked or tiled.
  3653.    . 28 window-relative writing routines.
  3654.    . 15 different border styles with shadow and zoom effects.
  3655.    . Full line drawing procedures.
  3656.    . Full cursor mode control for each window.
  3657.    . Writes in all text modes and column modes.
  3658.    . Only 13k bytes of code if all 69 utilities are used.
  3659.    . Used in all other Eagle products.
  3660.  
  3661.    Here are the product versions:
  3662.  
  3663.       File name    CIS name    Compiler  Release date
  3664.       -----------  ----------  --------  ------------
  3665.       WNDW42A.ARC  WNDW42.ARC  TP4(TP5)   10-15-88
  3666.       WNDW5XA.ARC  WNDW5X.ARC  TP5(TP4)   12-20-88
  3667.       WNDW50.ARC   WNDW50.ARC  TP5        TBA
  3668.       WNDWC20.ARC  WNDC20.ARC  TC2        02-01-89
  3669.  
  3670.  
  3671.    PULL
  3672.  
  3673.    Here are the product versions:
  3674.  
  3675.       File name    CIS name    Compiler  Release date
  3676.       -----------  ----------  --------  ------------
  3677.       PULL42A.ARC  PULL42.ARC  TP4(TP5)   01-03-89
  3678.       PULL5XA.ARC  PULL5X.ARC  TP5(TP4)   01-07-89
  3679.       PULL50.ARC   PULL50.ARC  TP5        TBA
  3680.       PULLC20.ARC  PULC20.ARC  TC2        TBA
  3681.  
  3682.  
  3683.    ON-LINE SERVICES
  3684.  
  3685.    CompuServe - All updated files and later versions can be found on the 
  3686.    CompuServe Borland Forums (GO BPROGA for TP and GO BPROGB for TC) or the 
  3687.    IBM Programming Forum (GO IBMPRO).
  3688.  
  3689.  
  3690.    RELEASE DATES
  3691.  
  3692.    Please note that the release dates are only estimates.
  3693.  
  3694.  
  3695.  
  3696.  
  3697.  
  3698.  
  3699.  
  3700.    Appendix A: Other Products                                          Page 61
  3701.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  3702.  
  3703.  
  3704.    A P P E N D I X   B :   R E V I S I O N   H I S T O R Y
  3705.  
  3706.    REVISIONS:
  3707.  
  3708.    Version 1.1 (02-27-87): Initial release
  3709.    Version 1.2 (04-08-87): limited release
  3710.    Version 1.3 (04-20-87)
  3711.    Version 1.4 (06-30-87): limited release
  3712.    Version 1.5 (08-31-87):
  3713.  
  3714.    Version 2.0 (01-12-88):
  3715.      . Converted to TP4 and incorporated QWIK40 and PULL40.
  3716.      . Added pull-down directory with path and mask.
  3717.      . Added global keys like Alt-F and Alt-X in PULLSTAT.PAS.
  3718.      . Eliminated PULLUSER.INC and instead allow access to user 
  3719.          windows direct through PullProc.Process.
  3720.      . Menu partitions now use Wndw.BrdrRec.
  3721.      . Added TypeOfDataTypes Word and LongInt.
  3722.      . Added "ClearScreen" option in InitPull.
  3723.      . Deleted i and j variables in PULL20.PAS.
  3724.      . Modified Pull.TempMsg; Deleted TempMsgArray.
  3725.      . Top menu record is available from TopMenuRecPtr^.
  3726.  
  3727.    Version 4.2 (01-03-89):
  3728.      . Incorporated QWIK42 and WNDW42.
  3729.      . Added excellent documentation.
  3730.      . Expanded the fill-in-the-blank concept.
  3731.      . Simplified work window data entry with sequential data entry
  3732.        routines.
  3733.      . Changed data windows to the slide-under configuration.
  3734.      . Added complete editing in data entry fields.
  3735.      . Added custom set control for data entry and deleted UserStrings.
  3736.      . Added key translation and range checking pointers.
  3737.      . Added multi-level window control.
  3738.      . Deleted PullProc.pas and the Process and Transfer procedures and
  3739.        replaced them with pointers.
  3740.      . Added automatic menu and line counting.
  3741.      . Simplified Menu Modes with execution pointers.
  3742.      . Changed menu records from global to dynamic data.
  3743.      . Improved submenu linking following the direction trend of the parent 
  3744.        menu.
  3745.  
  3746.    Version 5.X (01-07-89):
  3747.      . Compiled PULL42 under TP5.  No other changes.
  3748.  
  3749.    Version 5.Xa (01-11-89):
  3750.      . Corrected right-arrow key problem in data entry (P5X-DATA.INC).
  3751.      . Improved cursor mode handling during dynamic updates.
  3752.  
  3753.  
  3754.  
  3755.  
  3756.  
  3757.  
  3758.  
  3759.  
  3760.  
  3761.    Appendix B: Revision History                                        Page 62
  3762.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  3763.  
  3764.  
  3765.    A P P E N D I X   C :   C R E D I T S
  3766.  
  3767.    Art Hill started some initial ideas on this with PullDown.arc
  3768.  
  3769.       Art Hill 
  3770.       936 S. Kensington Ave.
  3771.       La Grange, IL 60525
  3772.       CIS 72307,3570
  3773.  
  3774.    Copyright (c) 1986-1988 by James H. LeMay for Eagle Performance Software.
  3775.    All Rights Reserved.  Protected by the United States Copyright Laws.
  3776.  
  3777.    Turbo Pascal is a trademark of Borland International.
  3778.    WordStar is a trademark of MicroPro International.
  3779.  
  3780.  
  3781.  
  3782.  
  3783.  
  3784.  
  3785.  
  3786.  
  3787.  
  3788.  
  3789.  
  3790.  
  3791.  
  3792.  
  3793.  
  3794.  
  3795.  
  3796.  
  3797.  
  3798.  
  3799.  
  3800.  
  3801.  
  3802.  
  3803.  
  3804.  
  3805.  
  3806.  
  3807.  
  3808.  
  3809.  
  3810.  
  3811.  
  3812.  
  3813.  
  3814.  
  3815.  
  3816.  
  3817.  
  3818.  
  3819.  
  3820.  
  3821.  
  3822.    Appendix C: Credits                                                 Page 63
  3823.    PULL Multi-level Pull-Down Menus                 User's Guide, Version 5.Xa
  3824.  
  3825.  
  3826.    A P P E N D I X   D :   G L O S S A R Y
  3827.  
  3828.    Command letter - A letter highlighted in a menu that executes that line.
  3829.    Command sequence - The sequence of command letters pressed to arrive at a 
  3830.                    window or menu.
  3831.    Data entry    - Field for entering data into the application program in the 
  3832.                    work windows or user windows.
  3833.    Data window   - Window for entering data into the application program from 
  3834.                    the menus.
  3835.    Error message - A short message for data out of range.
  3836.    Field         - A highlighted area reserved for a data entry string to be 
  3837.                    displayed.
  3838.    Flex field    - A field that allows more characters into the data entry 
  3839.                    than what the field displays.
  3840.    Free field    - A field that allows a continuous string of characters to 
  3841.                    expand in the field in any position.  This is in contrast 
  3842.                    to formatted fields where each column is designated an 
  3843.                    entry.
  3844.    Local key     - A key that only works within the menu or window.
  3845.    Gated exit    - A procedure that lets the flow of execution pass through 
  3846.                    back to PULL's key dispatcher only on specific keystrokes.
  3847.    Global key    - A key that accesses a different part of the program at any 
  3848.                    time.
  3849.    Help message  - A message appear on the message line for keyboard 
  3850.                    instructions.
  3851.    Help window   - A window displayed by pressing F1 that provides context-
  3852.                    sensitive help.
  3853.    HiLited       - A highlighted bar pointed at in a menu.
  3854.    Level         - A window or menu where the program is operating.
  3855.    Line          - A row of text.
  3856.    Link          - A menu line showing a symbol (three-bar or dot) that pulls 
  3857.                    another menu or window.  The symbol is also on the same 
  3858.                    side where it is pulled.
  3859.    Main menu     - The first menu pulled from the Top Line menu.
  3860.    Menu          - A list of selectable lines.
  3861.    Message line  - The bottom row to display key helps or processing status.
  3862.    Pop           - removes menu and returns to the previous menu.
  3863.    PullDown      - pulls menus down to the previous level.
  3864.    Selection     - A line selected in a menu with a CR.
  3865.    Shell         - A bare bones program of pull-down menus to get you started 
  3866.                    in your own application.
  3867.    Slide-under   - The configuration of data windows them to slide under the 
  3868.                    HiLite if the field grows wider.
  3869.    Slide-up      - The configuration of submenus that allows them to slide 
  3870.                    upward as the menu list grows.
  3871.    Status line   - A optional line reserved for status information pertinent 
  3872.                    to your program.
  3873.    Submenu       - All subsequent menus pulled after a main menu.
  3874.    Top Line menu - The menu always shown (usually in row 1 or 2).
  3875.    Window        - Not a menu.
  3876.    Work window   - The window where the bulk of the application is shown.
  3877.  
  3878.  
  3879.  
  3880.  
  3881.  
  3882.  
  3883.    Appendix D: Glossary                                                Page 64
  3884.